Zelda Classic Coverage Report


Directory: src/
File: src/zc/zc_sys.cpp
Date: 2023-08-22 06:09:56
Exec Total Coverage
Lines: 1672 4277 39.1%
Functions: 129 333 38.7%
Branches: 914 2804 32.6%

Line Branch Exec Source
1 //--------------------------------------------------------
2 // ZQuest Classic
3 // by Jeremy Craner, 1999-2000
4 //
5 // zc_sys.cc
6 //
7 // System functions, input handlers, GUI stuff, etc.
8 // for ZQuest Classic.
9 //
10 //--------------------------------------------------------
11
12 #include "zc/zc_sys.h"
13
14 #include "base/qrs.h"
15 #include "base/dmap.h"
16 #include <stdio.h>
17 #include <stdlib.h>
18 #include <string.h>
19 #include <math.h>
20 #include <map>
21 #include <filesystem>
22 #include <ctype.h>
23 #include <sstream>
24 #include "base/zc_alleg.h"
25 #include "gamedata.h"
26 #include "zc/zc_init.h"
27 #include "init.h"
28 #include "zc/replay.h"
29 #include "zc/cheats.h"
30 #include "zc/render.h"
31 #include "base/zc_math.h"
32 #include "base/zapp.h"
33 #include "dialog/cheatkeys.h"
34 #include "metadata/metadata.h"
35 #include "zc/zelda.h"
36 #include "zc/saves.h"
37 #include "tiles.h"
38 #include "base/colors.h"
39 #include "pal.h"
40 #include "base/zsys.h"
41 #include "qst.h"
42 #include "zc/zc_sys.h"
43 #include "play_midi.h"
44 #include "jwin_a5.h"
45 #include "base/jwinfsel.h"
46 #include "base/gui.h"
47 #include "midi.h"
48 #include "subscr.h"
49 #include "zc/maps.h"
50 #include "sprite.h"
51 #include "zc/guys.h"
52 #include "zc/hero.h"
53 #include "zc/title.h"
54 #include "particles.h"
55 #include "zcmusic.h"
56 #include "zconsole.h"
57 #include "zc/ffscript.h"
58 #include "dialog/info.h"
59 #include "dialog/alert.h"
60 #include "zc/combos.h"
61 #include "zc/jit.h"
62 #include <fmt/format.h>
63 #include "zinfo.h"
64 #include "base/misctypes.h"
65
66 #ifdef __EMSCRIPTEN__
67 #include "base/emscripten_utils.h"
68 #endif
69
70 extern FFScript FFCore;
71 extern bool Playing;
72 int32_t sfx_voice[WAV_COUNT];
73 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c);
74 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c);
75
76 extern byte monochrome_console;
77
78 extern HeroClass Hero;
79 extern ZModule zcm;
80 extern zcmodule moduledata;
81 extern sprite_list guys, items, Ewpns, Lwpns, chainlinks, decorations;
82 extern particle_list particles;
83 extern int32_t loadlast;
84 extern char *sfx_string[WAV_COUNT];
85 byte use_dwm_flush;
86 byte use_save_indicator;
87 int32_t paused_midi_pos = 0;
88 byte midi_suspended = 0;
89 byte zc_192b163_warp_compatibility;
90 char modulepath[2048];
91 bool epilepsyFlashReduction;
92 signed char pause_in_background_menu_init = 0;
93 byte pause_in_background = 0;
94 bool is_sys_pal = false;
95 static bool load_control_called_this_frame;
96 extern PALETTE* hw_palette;
97 extern bool update_hw_pal;
98 extern const char* dmaplist(int32_t index, int32_t* list_size);
99 int32_t getnumber(const char *prompt,int32_t initialval);
100
101 extern bool kb_typing_mode; //script only, for disbaling key presses affecting Hero, etc.
102 extern int32_t cheat_modifier_keys[4]; //two options each, default either control and either shift
103 //extern byte refresh_select_screen;
104 //extern movingblock mblock2; //mblock[4]?
105 //extern int32_t db;
106
107 static const char *ZC_str = "ZQuest Classic";
108 #if defined(ALLEGRO_WINDOWS)
109 const char *qst_dir_name = "win_qst_dir";
110 static const char *qst_module_name = "current_module";
111 #elif defined(ALLEGRO_LINUX)
112 const char *qst_dir_name = "linux_qst_dir";
113 static const char *qst_module_name = "current_module";
114 #elif defined(__APPLE__)
115 const char *qst_dir_name = "osx_qst_dir";
116 static const char *qst_module_name = "current_module";
117 #endif
118 #ifdef ALLEGRO_LINUX
119 static const char *samplepath = "samplesoundset/patches.dat";
120 #endif
121 char qst_files_path[2048];
122
123 #ifdef _MSC_VER
124 #define getcwd _getcwd
125 #endif
126
127 bool rF11();
128 bool rI();
129 bool rQ();
130 bool zc_key_pressed();
131
132 #ifdef _WIN32
133
134 // This should only be necessary for MinGW, since it doesn't have a dwmapi.h. Add another #ifdef if you like.
135 extern "C"
136 {
137 typedef HRESULT(WINAPI *t_DwmFlush)();
138 typedef HRESULT(WINAPI *t_DwmIsCompositionEnabled)(BOOL *pfEnabled);
139 }
140
141 void do_DwmFlush()
142 {
143 static HMODULE shell = LoadLibrary("dwmapi.dll");
144
145 if(!shell)
146 return;
147
148 static t_DwmFlush flush=reinterpret_cast<t_DwmFlush>(GetProcAddress(shell, "DwmFlush"));
149 static t_DwmIsCompositionEnabled isEnabled=reinterpret_cast<t_DwmIsCompositionEnabled>(GetProcAddress(shell, "DwmIsCompositionEnabled"));
150
151 BOOL enabled;
152 isEnabled(&enabled);
153
154 if(isEnabled)
155 flush();
156 }
157
158 #endif // _WIN32
159
160 83751 bool flash_reduction_enabled(bool check_qr)
161 {
162
4/4
✓ Branch 0 taken 81530 times.
✓ Branch 1 taken 2221 times.
✓ Branch 2 taken 81074 times.
✓ Branch 3 taken 83295 times.
83751 return (check_qr && get_qr(qr_EPILEPSY)) || epilepsyFlashReduction || replay_is_debug();
163 }
164
165 // Dialogue largening
166 void large_dialog(DIALOG *d)
167 {
168 large_dialog(d, 1.5);
169 }
170
171 void large_dialog(DIALOG *d, float RESIZE_AMT)
172 {
173 if(!d[0].d1)
174 {
175 d[0].d1 = 1;
176 int32_t oldwidth = d[0].w;
177 int32_t oldheight = d[0].h;
178 int32_t oldx = d[0].x;
179 int32_t oldy = d[0].y;
180 d[0].x -= int32_t(d[0].w/RESIZE_AMT);
181 d[0].y -= int32_t(d[0].h/RESIZE_AMT);
182 d[0].w = int32_t(d[0].w*RESIZE_AMT);
183 d[0].h = int32_t(d[0].h*RESIZE_AMT);
184
185 for(int32_t i=1; d[i].proc !=NULL; i++)
186 {
187 // Place elements horizontally
188 double xpc = ((double)(d[i].x - oldx) / (double)oldwidth);
189 d[i].x = int32_t(d[0].x + (xpc*d[0].w));
190
191 if(d[i].proc != d_stringloader)
192 {
193 if(d[i].proc==d_bitmap_proc)
194 {
195 d[i].w *= 2;
196 }
197 else d[i].w = int32_t(d[i].w*RESIZE_AMT);
198 }
199
200 // Place elements vertically
201 double ypc = ((double)(d[i].y - oldy) / (double)oldheight);
202 d[i].y = int32_t(d[0].y + (ypc*d[0].h));
203
204 // Vertically resize elements
205 if(d[i].proc == jwin_edit_proc || d[i].proc == jwin_check_proc || d[i].proc == jwin_checkfont_proc)
206 {
207 d[i].h = int32_t((double)d[i].h*1.5);
208 }
209 else if(d[i].proc == jwin_droplist_proc)
210 {
211 d[i].y += int32_t((double)d[i].h*0.25);
212 d[i].h = int32_t((double)d[i].h*1.25);
213 }
214 else if(d[i].proc==d_bitmap_proc)
215 {
216 d[i].h *= 2;
217 }
218 else d[i].h = int32_t(d[i].h*RESIZE_AMT);
219
220 // Fix frames
221 if(d[i].proc == jwin_frame_proc)
222 {
223 d[i].x++;
224 d[i].y++;
225 d[i].w-=4;
226 d[i].h-=4;
227 }
228 }
229 }
230
231 for(int32_t i=1; d[i].proc!=NULL; i++)
232 {
233 if(d[i].proc==jwin_slider_proc)
234 continue;
235
236 // Bigger font
237 bool bigfontproc = (d[i].proc != d_midilist_proc && d[i].proc != jwin_droplist_proc && d[i].proc != jwin_abclist_proc && d[i].proc != jwin_list_proc);
238
239 if(!d[i].dp2 && bigfontproc)
240 {
241 d[i].dp2 = get_zc_font(font_lfont_l);
242 }
243 else if(!bigfontproc)
244 {
245 ((ListData *)d[i].dp)->font = &a4fonts[font_lfont_l];
246 }
247
248 // Make checkboxes work
249 if(d[i].proc == jwin_check_proc)
250 d[i].proc = jwin_checkfont_proc;
251 else if(d[i].proc == jwin_radio_proc)
252 d[i].proc = jwin_radiofont_proc;
253 }
254
255 jwin_center_dialog(d);
256 }
257
258
259 /**********************************/
260 /******** System functions ********/
261 /**********************************/
262
263 static char cfg_sect[] = "zeldadx"; //We need to rename this.
264 static char ctrl_sect[] = "Controls";
265 static char sfx_sect[] = "Volume";
266
267 int32_t d_dummy_proc(int32_t,DIALOG *,int32_t)
268 {
269 return D_O_K;
270 }
271
272 bool is_reserved_key(int c)
273 {
274 switch(c)
275 {
276 case KEY_ESC:
277 return true;
278 }
279 return false;
280 }
281 bool is_reserved_keycombo(int c, int modflag)
282 {
283 if(c==KEY_F4 && (modflag&KB_ALT_FLAG))
284 return true;
285 return false;
286 }
287 bool checkcheat(Cheat cheat)
288 {
289 if(cheatkeys[cheat][0] && zc_readkey(cheatkeys[cheat][0]))
290 return true; //Main key pressed
291 if(cheatkeys[cheat][1] && zc_readkey(cheatkeys[cheat][1]))
292 return true; //Alt key pressed
293 return false;
294 }
295 114 void load_default_cheatkeys()
296 {
297 114 memset(cheatkeys, 0, sizeof(cheatkeys));
298 114 cheatkeys[Cheat::Life][0] = KEY_H;
299 114 cheatkeys[Cheat::Life][1] = KEY_ASTERISK;
300 114 cheatkeys[Cheat::Magic][0] = KEY_M;
301 114 cheatkeys[Cheat::Magic][1] = KEY_SLASH_PAD;
302 114 cheatkeys[Cheat::Rupies][0] = KEY_R;
303 114 cheatkeys[Cheat::Bombs][0] = KEY_B;
304 114 cheatkeys[Cheat::Arrows][0] = KEY_A;
305 114 cheatkeys[Cheat::Clock][0] = KEY_I;
306 114 cheatkeys[Cheat::Walls][0] = KEY_F11;
307 114 cheatkeys[Cheat::Fast][0] = KEY_Q;
308 114 cheatkeys[Cheat::Light][0] = KEY_L;
309 114 cheatkeys[Cheat::IgnoreSideView][0] = KEY_V;
310 114 cheatkeys[Cheat::Kill][0] = KEY_K;
311 114 cheatkeys[Cheat::GoTo][0] = KEY_G;
312 114 cheatkeys[Cheat::TrigSecrets][0] = KEY_S;
313 114 cheatkeys[Cheat::ShowL0][0] = KEY_0;
314 114 cheatkeys[Cheat::ShowL1][0] = KEY_1;
315 114 cheatkeys[Cheat::ShowL2][0] = KEY_2;
316 114 cheatkeys[Cheat::ShowL3][0] = KEY_3;
317 114 cheatkeys[Cheat::ShowL4][0] = KEY_4;
318 114 cheatkeys[Cheat::ShowL5][0] = KEY_5;
319 114 cheatkeys[Cheat::ShowL6][0] = KEY_6;
320 114 cheatkeys[Cheat::ShowFFC][0] = KEY_7;
321 114 cheatkeys[Cheat::ShowSprites][0] = KEY_8;
322 114 cheatkeys[Cheat::ShowWalkability][0] = KEY_W;
323 114 cheatkeys[Cheat::ShowEffects][0] = KEY_E;
324 114 cheatkeys[Cheat::ShowOverhead][0] = KEY_O;
325 114 cheatkeys[Cheat::ShowPushblock][0] = KEY_P;
326 114 cheatkeys[Cheat::ShowHitbox][0] = KEY_C;
327 114 cheatkeys[Cheat::ShowFFCScripts][0] = KEY_F;
328 114 }
329 114 void load_game_configs()
330 {
331 114 strcpy(moduledata.module_name,zc_get_config("ZCMODULE",qst_module_name,"classic.zmod"));
332 114 joystick_index = zc_get_config(ctrl_sect,"joystick_index",0);
333 114 js_stick_1_x_stick = zc_get_config(ctrl_sect,"js_stick_1_x_stick",0);
334 114 js_stick_1_x_axis = zc_get_config(ctrl_sect,"js_stick_1_x_axis",0);
335 114 js_stick_1_x_offset = zc_get_config(ctrl_sect,"js_stick_1_x_offset",0) ? 128 : 0;
336 114 js_stick_1_y_stick = zc_get_config(ctrl_sect,"js_stick_1_y_stick",0);
337 114 js_stick_1_y_axis = zc_get_config(ctrl_sect,"js_stick_1_y_axis",1);
338 114 js_stick_1_y_offset = zc_get_config(ctrl_sect,"js_stick_1_y_offset",0) ? 128 : 0;
339 114 js_stick_2_x_stick = zc_get_config(ctrl_sect,"js_stick_2_x_stick",1);
340 114 js_stick_2_x_axis = zc_get_config(ctrl_sect,"js_stick_2_x_axis",0);
341 114 js_stick_2_x_offset = zc_get_config(ctrl_sect,"js_stick_2_x_offset",0) ? 128 : 0;
342 114 js_stick_2_y_stick = zc_get_config(ctrl_sect,"js_stick_2_y_stick",1);
343 114 js_stick_2_y_axis = zc_get_config(ctrl_sect,"js_stick_2_y_axis",1);
344 114 js_stick_2_y_offset = zc_get_config(ctrl_sect,"js_stick_2_y_offset",0) ? 128 : 0;
345 114 analog_movement = (zc_get_config(ctrl_sect,"analog_movement",1));
346
347 //cheat modifier keya
348 114 cheat_modifier_keys[0] = zc_get_config(ctrl_sect,"key_cheatmod_a1",KEY_ZC_LCONTROL);
349 114 cheat_modifier_keys[1] = zc_get_config(ctrl_sect,"key_cheatmod_a2",0);
350 114 cheat_modifier_keys[2] = zc_get_config(ctrl_sect,"key_cheatmod_b1",KEY_ZC_RCONTROL);
351 114 cheat_modifier_keys[3] = zc_get_config(ctrl_sect,"key_cheatmod_b2",0);
352
353 //cheat keys
354 114 load_default_cheatkeys();
355 char buf[256];
356
2/2
✓ Branch 0 taken 3990 times.
✓ Branch 1 taken 114 times.
4104 for(size_t q = 1; q < Cheat::Last; ++q)
357 {
358
1/2
✓ Branch 0 taken 3990 times.
✗ Branch 1 not taken.
3990 if(!bindable_cheat((Cheat)q)) continue;
359 3990 std::string cheatname = cheat_to_string((Cheat)q);
360
1/2
✓ Branch 0 taken 3990 times.
✗ Branch 1 not taken.
3990 util::lowerstr(cheatname);
361 3990 sprintf(buf, "key_cheat_%s_main", cheatname.c_str());
362
1/2
✓ Branch 0 taken 3990 times.
✗ Branch 1 not taken.
3990 cheatkeys[q][0] = zc_get_config(ctrl_sect,buf,cheatkeys[q][0]);
363 3990 sprintf(buf, "key_cheat_%s_alt", cheatname.c_str());
364
1/2
✓ Branch 0 taken 3990 times.
✗ Branch 1 not taken.
3990 cheatkeys[q][1] = zc_get_config(ctrl_sect,buf,cheatkeys[q][1]);
365 3990 }
366
367
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if((uint32_t)joystick_index >= MAX_JOYSTICKS)
368 joystick_index = 0;
369
370 114 Akey = zc_get_config(ctrl_sect,"key_a",KEY_Z);
371 114 Bkey = zc_get_config(ctrl_sect,"key_b",KEY_X);
372 114 Skey = zc_get_config(ctrl_sect,"key_s",KEY_ENTER);
373 114 Lkey = zc_get_config(ctrl_sect,"key_l",KEY_Q);
374 114 Rkey = zc_get_config(ctrl_sect,"key_r",KEY_W);
375 114 Pkey = zc_get_config(ctrl_sect,"key_p",KEY_SPACE);
376 114 Exkey1 = zc_get_config(ctrl_sect,"key_ex1",KEY_A);
377 114 Exkey2 = zc_get_config(ctrl_sect,"key_ex2",KEY_S);
378 114 Exkey3 = zc_get_config(ctrl_sect,"key_ex3",KEY_D);
379 114 Exkey4 = zc_get_config(ctrl_sect,"key_ex4",KEY_C);
380
381 114 DUkey = zc_get_config(ctrl_sect,"key_up", KEY_UP);
382 114 DDkey = zc_get_config(ctrl_sect,"key_down", KEY_DOWN);
383 114 DLkey = zc_get_config(ctrl_sect,"key_left", KEY_LEFT);
384 114 DRkey = zc_get_config(ctrl_sect,"key_right",KEY_RIGHT);
385
386 114 Abtn = zc_get_config(ctrl_sect,"btn_a",2);
387 114 Bbtn = zc_get_config(ctrl_sect,"btn_b",1);
388 114 Sbtn = zc_get_config(ctrl_sect,"btn_s",10);
389 114 Mbtn = zc_get_config(ctrl_sect,"btn_m",9);
390 114 Lbtn = zc_get_config(ctrl_sect,"btn_l",5);
391 114 Rbtn = zc_get_config(ctrl_sect,"btn_r",6);
392 114 Pbtn = zc_get_config(ctrl_sect,"btn_p",12);
393 114 Exbtn1 = zc_get_config(ctrl_sect,"btn_ex1",7);
394 114 Exbtn2 = zc_get_config(ctrl_sect,"btn_ex2",8);
395 114 Exbtn3 = zc_get_config(ctrl_sect,"btn_ex3",4);
396 114 Exbtn4 = zc_get_config(ctrl_sect,"btn_ex4",3);
397
398 114 DUbtn = zc_get_config(ctrl_sect,"btn_up",13);
399 114 DDbtn = zc_get_config(ctrl_sect,"btn_down",14);
400 114 DLbtn = zc_get_config(ctrl_sect,"btn_left",15);
401 114 DRbtn = zc_get_config(ctrl_sect,"btn_right",16);
402
403 114 epilepsyFlashReduction = zc_get_config(cfg_sect,"epilepsy_flash_reduction",0);
404
405 114 digi_volume = zc_get_config(sfx_sect,"digi",248);
406 114 midi_volume = zc_get_config(sfx_sect,"midi",255);
407 114 sfx_volume = zc_get_config(sfx_sect,"sfx",248);
408 114 emusic_volume = zc_get_config(sfx_sect,"emusic",248);
409 114 pan_style = zc_get_config(sfx_sect,"pan",1);
410 // 1 <= zcmusic_bufsz <= 128
411 114 zcmusic_bufsz = vbound(zc_get_config(sfx_sect,"zcmusic_bufsz",64),1,128);
412 114 volkeys = zc_get_config(sfx_sect,"volkeys",0)!=0;
413 114 zc_vsync = zc_get_config(cfg_sect,"vsync",0);
414 114 Throttlefps = zc_get_config(cfg_sect,"throttlefps",1)!=0;
415 114 TransLayers = zc_get_config(cfg_sect,"translayers",1)!=0;
416 114 SnapshotFormat = zc_get_config(cfg_sect,"snapshot_format",3);
417 114 NameEntryMode = zc_get_config(cfg_sect,"name_entry_mode",0);
418 #ifdef __EMSCRIPTEN__
419 if (em_is_mobile()) NameEntryMode = 2;
420 #endif
421 114 ShowFPS = zc_get_config(cfg_sect,"showfps",0)!=0;
422 114 NESquit = zc_get_config(cfg_sect,"fastquit",0)!=0;
423 114 ClickToFreeze = zc_get_config(cfg_sect,"clicktofreeze",1)!=0;
424 114 title_version = zc_get_config(cfg_sect,"title",2);
425 114 abc_patternmatch = zc_get_config(cfg_sect, "lister_pattern_matching", 1);
426 114 pause_in_background = zc_get_config(cfg_sect, "pause_in_background", 0);
427
428 //default - scale x2, 640 x 480
429 114 window_width = resx = zc_get_config(cfg_sect,"window_width",640);
430 114 window_height = resy = zc_get_config(cfg_sect,"window_height",480);
431 114 SaveDragResize = zc_get_config(cfg_sect,"save_drag_resize",0)!=0;
432 114 DragAspect = zc_get_config(cfg_sect,"drag_aspect",0)!=0;
433 114 SaveWinPos = zc_get_config(cfg_sect,"save_window_position",0)!=0;
434 114 scaleForceInteger = zc_get_config("zeldadx","scaling_force_integer",1)!=0;
435 114 stretchGame = zc_get_config("zeldadx","stretch_game_area",0)!=0;
436
437 114 loadlast = zc_get_config(cfg_sect,"load_last",0);
438
439 114 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
440
441 114 zc_color_depth = (byte) zc_get_config(cfg_sect,"color_depth",8);
442
443 114 forceExit = (byte) zc_get_config(cfg_sect,"force_exit",0);
444 114 info_opacity = zc_get_config("zc","debug_info_opacity",255);
445 #ifdef _WIN32
446 zasm_debugger = (byte) zc_get_config("CONSOLE","print_ZASM",0);
447 zscript_debugger = (byte) zc_get_config("CONSOLE","ZScript_Debugger",0);
448 //use_win7_keyboard_fix = (byte) zc_get_config(cfg_sect,"use_win7_key_fix",0);
449 use_win32_proc = (byte) zc_get_config(cfg_sect,"zc_win_proc_fix",0); //buggy
450
451 // This one's for Aero
452 use_dwm_flush = (byte) zc_get_config("zeldadx","use_dwm_flush",0);
453
454 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
455 #else //UNIX
456 114 zasm_debugger = (byte) zc_get_config("CONSOLE","print_ZASM",0);
457 114 zscript_debugger = (byte) zc_get_config("CONSOLE","ZScript_Debugger",0);
458 114 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
459 #endif
460 114 clearConsoleOnLoad = zc_get_config("CONSOLE","clear_console_on_load",1)!=0;
461 114 clearConsoleOnReload = zc_get_config("CONSOLE","clear_console_on_reload",0)!=0;
462
463 114 strcpy(qstdir,zc_get_config(cfg_sect,qst_dir_name,""));
464
465
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(strlen(qstdir)==0)
466 {
467 114 getcwd(qstdir,2048);
468 114 fix_filename_case(qstdir);
469 114 fix_filename_slashes(qstdir);
470 114 put_backslash(qstdir);
471 114 }
472 else
473 {
474 chop_path(qstdir);
475 }
476
477 114 strcpy(qstpath,qstdir); //qstpath is the local (for this run of ZC) quest path, qstdir is the universal quest dir.
478 114 ss_enable = zc_get_config(cfg_sect,"ss_enable",1) ? 1 : 0;
479 114 ss_after = vbound(zc_get_config(cfg_sect,"ss_after",14), 0, 14);
480 114 ss_speed = vbound(zc_get_config(cfg_sect,"ss_speed",2), 0, 6);
481 114 ss_density = vbound(zc_get_config(cfg_sect,"ss_density",3), 0, 6);
482 114 heart_beep = zc_get_config(cfg_sect,"heart_beep",1)!=0;
483 //gui_colorset = zc_get_config(cfg_sect,"gui_colorset",0);
484 114 sfxdat = zc_get_config(cfg_sect,"use_sfx_dat",1);
485 114 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
486 114 use_save_indicator = zc_get_config(cfg_sect,"save_indicator",0);
487 114 zc_192b163_warp_compatibility = zc_get_config(cfg_sect,"zc_192b163_warp_compatibility",0);
488 114 }
489
490 void save_control_configs(bool kb)
491 {
492 if(kb)
493 {
494 zc_set_config(ctrl_sect,"key_cheatmod_a1",cheat_modifier_keys[0]);
495 zc_set_config(ctrl_sect,"key_cheatmod_a2",cheat_modifier_keys[1]);
496 zc_set_config(ctrl_sect,"key_cheatmod_b1",cheat_modifier_keys[2]);
497 zc_set_config(ctrl_sect,"key_cheatmod_b2",cheat_modifier_keys[3]);
498
499 if (!replay_is_replaying())
500 {
501 zc_set_config(ctrl_sect,"key_a",Akey);
502 zc_set_config(ctrl_sect,"key_b",Bkey);
503 zc_set_config(ctrl_sect,"key_s",Skey);
504 zc_set_config(ctrl_sect,"key_l",Lkey);
505 zc_set_config(ctrl_sect,"key_r",Rkey);
506 zc_set_config(ctrl_sect,"key_p",Pkey);
507 zc_set_config(ctrl_sect,"key_ex1",Exkey1);
508 zc_set_config(ctrl_sect,"key_ex2",Exkey2);
509 zc_set_config(ctrl_sect,"key_ex3",Exkey3);
510 zc_set_config(ctrl_sect,"key_ex4",Exkey4);
511 zc_set_config(ctrl_sect,"key_up", DUkey);
512 zc_set_config(ctrl_sect,"key_down", DDkey);
513 zc_set_config(ctrl_sect,"key_left", DLkey);
514 zc_set_config(ctrl_sect,"key_right",DRkey);
515 }
516 }
517 else
518 {
519 zc_set_config(ctrl_sect,"joystick_index",joystick_index);
520 zc_set_config(ctrl_sect,"js_stick_1_x_stick",js_stick_1_x_stick);
521 zc_set_config(ctrl_sect,"js_stick_1_x_axis",js_stick_1_x_axis);
522 zc_set_config(ctrl_sect,"js_stick_1_x_offset",js_stick_1_x_offset ? 1 : 0);
523 zc_set_config(ctrl_sect,"js_stick_1_y_stick",js_stick_1_y_stick);
524 zc_set_config(ctrl_sect,"js_stick_1_y_axis",js_stick_1_y_axis);
525 zc_set_config(ctrl_sect,"js_stick_1_y_offset",js_stick_1_y_offset ? 1 : 0);
526 zc_set_config(ctrl_sect,"js_stick_2_x_stick",js_stick_2_x_stick);
527 zc_set_config(ctrl_sect,"js_stick_2_x_axis",js_stick_2_x_axis);
528 zc_set_config(ctrl_sect,"js_stick_2_x_offset",js_stick_2_x_offset ? 1 : 0);
529 zc_set_config(ctrl_sect,"js_stick_2_y_stick",js_stick_2_y_stick);
530 zc_set_config(ctrl_sect,"js_stick_2_y_axis",js_stick_2_y_axis);
531 zc_set_config(ctrl_sect,"js_stick_2_y_offset",js_stick_2_y_offset ? 1 : 0);
532 zc_set_config(ctrl_sect,"analog_movement",analog_movement);
533
534 zc_set_config(ctrl_sect,"btn_a",Abtn);
535 zc_set_config(ctrl_sect,"btn_b",Bbtn);
536 zc_set_config(ctrl_sect,"btn_s",Sbtn);
537 zc_set_config(ctrl_sect,"btn_m",Mbtn);
538 zc_set_config(ctrl_sect,"btn_l",Lbtn);
539 zc_set_config(ctrl_sect,"btn_r",Rbtn);
540 zc_set_config(ctrl_sect,"btn_p",Pbtn);
541 zc_set_config(ctrl_sect,"btn_ex1",Exbtn1);
542 zc_set_config(ctrl_sect,"btn_ex2",Exbtn2);
543 zc_set_config(ctrl_sect,"btn_ex3",Exbtn3);
544 zc_set_config(ctrl_sect,"btn_ex4",Exbtn4);
545
546 zc_set_config(ctrl_sect,"btn_up",DUbtn);
547 zc_set_config(ctrl_sect,"btn_down",DDbtn);
548 zc_set_config(ctrl_sect,"btn_left",DLbtn);
549 zc_set_config(ctrl_sect,"btn_right",DRbtn);
550 }
551 }
552
553 void save_cheatkeys()
554 {
555 char buf[256];
556 for(size_t q = 1; q < Cheat::Last; ++q)
557 {
558 if(!bindable_cheat((Cheat)q)) continue;
559 std::string cheatname = cheat_to_string((Cheat)q);
560 util::lowerstr(cheatname);
561 sprintf(buf, "key_cheat_%s_main", cheatname.c_str());
562 zc_set_config(ctrl_sect,buf,cheatkeys[q][0]);
563 sprintf(buf, "key_cheat_%s_alt", cheatname.c_str());
564 if(cheatkeys[q][1])
565 zc_set_config(ctrl_sect,buf,cheatkeys[q][1]);
566 else zc_set_config(ctrl_sect,buf,(char*)nullptr);
567 }
568 }
569
570 void save_game_configs()
571 {
572 packfile_password("");
573
574 zc_set_config("ZCMODULE",qst_module_name,moduledata.module_name);
575
576 if (all_get_display() && !all_get_fullscreen_flag()&& SaveWinPos)
577 {
578 int o_window_x, o_window_y;
579 al_get_window_position(all_get_display(), &o_window_x, &o_window_y);
580 zc_set_config(cfg_sect,"window_x",o_window_x);
581 zc_set_config(cfg_sect,"window_y",o_window_y);
582 }
583
584 if (all_get_display() && !all_get_fullscreen_flag() && SaveDragResize)
585 {
586 double monitor_scale = zc_get_monitor_scale();
587 window_width = al_get_display_width(all_get_display()) / monitor_scale;
588 window_height = al_get_display_height(all_get_display()) / monitor_scale;
589 zc_set_config(cfg_sect,"window_width",window_width);
590 zc_set_config(cfg_sect,"window_height",window_height);
591 }
592
593 zc_set_config(cfg_sect,"load_last",loadlast);
594 chop_path(qstdir);
595 zc_set_config(cfg_sect,qst_dir_name,qstdir);
596 zc_set_config(cfg_sect,"use_sfx_dat",sfxdat);
597
598 flush_config_file();
599 #ifdef __EMSCRIPTEN__
600 em_sync_fs();
601 #endif
602 }
603
604 //----------------------------------------------------------------
605
606 // Timers
607
608 29772 void fps_callback()
609 {
610 29772 lastfps=framecnt;
611 29772 dword tempsecs = fps_secs;
612 29772 ++tempsecs;
613 //avgfps=((long double)avgfps*fps_secs+lastfps)/(++fps_secs); // DJGPP doesn't like this
614 29772 avgfps=((long double)avgfps*fps_secs+lastfps)/(tempsecs);
615 29772 ++fps_secs;
616 29772 framecnt=0;
617 29772 }
618
619 END_OF_FUNCTION(fps_callback)
620
621 114 int32_t Z_init_timers()
622 {
623 static bool didit = false;
624 const static char *err_str = "Couldn't allocate timer";
625 114 err_str = err_str; //Unused variable warning
626
627
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(didit)
628 return 1;
629
630 114 didit = true;
631
632 LOCK_VARIABLE(lastfps);
633 LOCK_VARIABLE(framecnt);
634 LOCK_FUNCTION(fps_callback);
635
636
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(install_int_ex(fps_callback,SECS_TO_TIMER(1)))
637 return 0;
638
639 114 return 1;
640 114 }
641
642 void Z_remove_timers()
643 {
644 remove_int(fps_callback);
645 }
646
647 //----------------------------------------------------------------
648
649 void go()
650 {
651 blit(screen,tmp_scr,scrx,scry,0,0,screen->w,screen->h);
652 }
653
654 void comeback()
655 {
656 blit(tmp_scr,screen,0,0,scrx,scry,screen->w,screen->h);
657 }
658
659 void dump_pal(BITMAP *dest)
660 {
661 for(int32_t i=0; i<256; i++)
662 rectfill(dest,(i&63)<<2,(i&0xFC0)>>4,((i&63)<<2)+3,((i&0xFC0)>>4)+3,i);
663 }
664
665 //----------------------------------------------------------------
666
667 int game_mouse_index = ZCM_BLANK;
668 static bool system_mouse = false;
669 28 bool sys_mouse()
670 {
671 28 system_mouse = true;
672 28 return MouseSprite::set(ZCM_NORMAL);
673 }
674 555 bool game_mouse()
675 {
676 555 system_mouse = false;
677 555 return MouseSprite::set(game_mouse_index);
678 }
679 void custom_mouse(BITMAP* bmp, int fx, int fy, bool sys_recolor, bool user_scale)
680 {
681 if(!bmp)
682 return;
683 float scale = vbound(zc_get_config("zeldadx","cursor_scale_large",1.5),1.0,5.0);
684 int scaledw = bmp->w*scale, scaledh = bmp->h*scale;
685 if(bmp->w == scaledw && bmp->h == scaledh)
686 user_scale = false;
687 if(user_scale || sys_recolor)
688 {
689 if(!user_scale) scale = 1;
690 BITMAP* tmpbmp = create_bitmap_ex(8,bmp->w*scale,bmp->h*scale);
691 if(user_scale)
692 stretch_blit(bmp, tmpbmp, 0, 0, bmp->w, bmp->h, 0, 0, tmpbmp->w, tmpbmp->h);
693 else
694 blit(bmp, tmpbmp, 0, 0, 0, 0, bmp->w, bmp->h);
695 if(sys_recolor)
696 recolor_mouse(tmpbmp);
697 MouseSprite::assign(ZCM_CUSTOM, tmpbmp, fx*scale, fy*scale);
698 destroy_bitmap(tmpbmp);
699 }
700 else
701 {
702 MouseSprite::assign(ZCM_CUSTOM, bmp, fx, fy);
703 }
704 }
705
706 //Handles converting the mouse sprite from the .dat file
707 void recolor_mouse(BITMAP* bmp)
708 {
709 for(int32_t x = 0; x < bmp->w; ++x)
710 {
711 for(int32_t y = 0; y < bmp->h; ++y)
712 {
713 int32_t color = getpixel(bmp, x, y);
714 switch(color)
715 {
716 case dvc(1):
717 color = jwin_pal[jcCURSORMISC];
718 break;
719 case dvc(2):
720 color = jwin_pal[jcCURSOROUTLINE];
721 break;
722 case dvc(3):
723 color = jwin_pal[jcCURSORLIGHT];
724 break;
725 case dvc(5):
726 color = jwin_pal[jcCURSORDARK];
727 break;
728 default:
729 continue;
730 }
731 putpixel(bmp, x, y, color);
732 }
733 }
734 }
735 void load_mouse()
736 {
737 enter_sys_pal();
738 MouseSprite::set(-1);
739 float scale = vbound(zc_get_config("zeldadx","cursor_scale_large",1.5),1.0,5.0);
740 int32_t sz = 16*scale;
741 for(int32_t j = 0; j < 1; ++j)
742 {
743 BITMAP* tmpbmp = create_bitmap_ex(8,16,16);
744 if(zcmouse[j])
745 destroy_bitmap(zcmouse[j]);
746 zcmouse[j] = create_bitmap_ex(8,sz,sz);
747 clear_bitmap(zcmouse[j]);
748 clear_bitmap(tmpbmp);
749 blit((BITMAP*)datafile[BMP_MOUSE].dat,tmpbmp,1,j*17+1,0,0,16,16);
750 recolor_mouse(tmpbmp);
751 if(sz!=16)
752 stretch_blit(tmpbmp, zcmouse[j], 0, 0, 16, 16, 0, 0, sz, sz);
753 else
754 blit(tmpbmp, zcmouse[j], 0, 0, 0, 0, 16, 16);
755 destroy_bitmap(tmpbmp);
756 }
757 if(!hw_palette) hw_palette = &RAMpal;
758 zc_set_palette(*hw_palette);
759
760 BITMAP* blankmouse = create_bitmap_ex(8,16,16);
761 clear_bitmap(blankmouse);
762
763 MouseSprite::assign(ZCM_NORMAL, zcmouse[0], 1*scale, 1*scale);
764 MouseSprite::assign(ZCM_BLANK, blankmouse);
765 //Don't assign ZCM_CUSTOM. That'll be handled by scripts.
766
767 //Reload the mouse
768 if(system_mouse)
769 sys_mouse();
770 else game_mouse();
771
772 destroy_bitmap(blankmouse);
773 exit_sys_pal();
774 }
775
776 // sets the video mode and initializes the palette and mouse sprite
777 114 bool game_vid_mode(int32_t mode,int32_t wait)
778 {
779
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if (is_headless())
780 114 return true;
781
782 if(set_gfx_mode(mode,resx,resy,0,0)!=0)
783 {
784 return false;
785 }
786
787 scrx = (resx-320)>>1;
788 scry = (resy-240)>>1;
789 for(int32_t q = 0; q < NUM_ZCMOUSE; ++q)
790 zcmouse[q] = NULL;
791 load_mouse();
792
793 for(int32_t i=240; i<256; i++)
794 RAMpal[i]=((RGB*)datafile[PAL_GUI].dat)[i];
795
796 zc_set_palette(RAMpal);
797 clear_to_color(screen,BLACK);
798
799 rest(wait);
800 return true;
801 114 }
802
803 8 void null_quest()
804 {
805 char qstdat_string[2048];
806 8 strcpy(qstdat_string, "modules/classic/default.qst");
807
808 #ifdef __EMSCRIPTEN__
809 // The quest template data file is not included because it's really big and isn't really needed
810 // for the player, except to initialize some graphics. Those same graphics exist in this quest file,
811 // which is much smaller.
812 strcpy(qstdat_string, "modules/classic/title_gfx.dat");
813 #endif
814
815 8 byte skip_flags[4] = { 0 };
816
817 8 loadquest(qstdat_string,&QHeader,&QMisc,tunes+ZC_MIDI_COUNT,false,skip_flags,0,false);
818 8 }
819
820 8 void init_NES_mode()
821 {
822 8 null_quest();
823 8 }
824
825 //----------------------------------------------------------------
826
827 qword trianglelines[16]=
828 {
829 0x0000000000000000ULL,
830 0xFD00000000000000ULL,
831 0xFDFD000000000000ULL,
832 0xFDFDFD0000000000ULL,
833 0xFDFDFDFD00000000ULL,
834 0xFDFDFDFDFD000000ULL,
835 0xFDFDFDFDFDFD0000ULL,
836 0xFDFDFDFDFDFDFD00ULL,
837 0xFDFDFDFDFDFDFDFDULL,
838 0x00FDFDFDFDFDFDFDULL,
839 0x0000FDFDFDFDFDFDULL,
840 0x000000FDFDFDFDFDULL,
841 0x00000000FDFDFDFDULL,
842 0x0000000000FDFDFDULL,
843 0x000000000000FDFDULL,
844 0x00000000000000FDULL,
845 };
846
847 word screen_triangles[28][32];
848 /*
849 qword triangles[4][16]= //[direction][value]
850 {
851 {
852 0x00000000, 0x10000000, 0x21000000, 0x32100000, 0x43210000, 0x54321000, 0x65432100, 0x76543210, 0x87654321, 0x88765432, 0x88876543, 0x88887654, 0x88888765, 0x88888876, 0x88888887, 0x88888888
853 },
854 {
855 0x00000000, 0xF0000000, 0xEF000000, 0xFDF00000, 0xCFDF0000, 0xBCFDF000, 0xABCFDF00, 0x9ABCFDF0, 0x89ABCFDF, 0x889ABCFD, 0x8889ABCD, 0x88889ABC, 0x888889AB, 0x8888889A, 0x88888889, 0x88888888
856 },
857 {
858 0x00000000, 0x00000001, 0x00000012, 0x00000123, 0x00001234, 0x00012345, 0x00123456, 0x01234567, 0x12345678, 0x23456788, 0x34567888, 0x45678888, 0x56788888, 0x67888888, 0x78888888, 0x88888888
859 },
860 {
861 0x00000000, 0x0000000F, 0x000000FE, 0x00000FED, 0x0000FEDC, 0x000FEDCB, 0x00FEDCBA, 0x0FEDCBA9, 0xFEDCBA98, 0xEDCBA988, 0xDCBA9888, 0xCBA98888, 0xBA988888, 0xA9888888, 0x98888888, 0x88888888
862 }
863 };
864 */
865
866
867 /*
868 byte triangles[4][16][8]= //[direction][value][line]
869 {
870 {
871 {
872 0, 0, 0, 0, 0, 0, 0, 0
873 },
874 {
875 1, 0, 0, 0, 0, 0, 0, 0
876 },
877 {
878 2, 1, 0, 0, 0, 0, 0, 0
879 },
880 {
881 3, 2, 1, 0, 0, 0, 0, 0
882 },
883 {
884 4, 3, 2, 1, 0, 0, 0, 0
885 },
886 {
887 5, 4, 3, 2, 1, 0, 0, 0
888 },
889 {
890 6, 5, 4, 3, 2, 1, 0, 0
891 },
892 {
893 7, 6, 5, 4, 3, 2, 1, 0
894 },
895 {
896 8, 7, 6, 5, 4, 3, 2, 1
897 },
898 {
899 8, 8, 7, 6, 5, 4, 3, 2
900 },
901 {
902 8, 8, 8, 7, 6, 5, 4, 3
903 },
904 {
905 8, 8, 8, 8, 7, 6, 5, 4
906 },
907 {
908 8, 8, 8, 8, 8, 7, 6, 5
909 },
910 {
911 8, 8, 8, 8, 8, 8, 7, 6
912 },
913 {
914 8, 8, 8, 8, 8, 8, 8, 7
915 },
916 {
917 8, 8, 8, 8, 8, 8, 8, 8
918 }
919 },
920 {
921 {
922 0, 0, 0, 0, 0, 0, 0, 0
923 },
924 {
925 15, 0, 0, 0, 0, 0, 0, 0
926 },
927 {
928 14, 15, 0, 0, 0, 0, 0, 0
929 },
930 {
931 13, 14, 15, 0, 0, 0, 0, 0
932 },
933 {
934 12, 13, 14, 15, 0, 0, 0, 0
935 },
936 {
937 11, 12, 13, 14, 15, 0, 0, 0
938 },
939 {
940 10, 11, 12, 13, 14, 15, 0, 0
941 },
942 {
943 9, 10, 11, 12, 13, 14, 15, 0
944 },
945 {
946 8, 9, 10, 11, 12, 13, 14, 15
947 },
948 {
949 8, 8, 9, 10, 11, 12, 13, 14
950 },
951 {
952 8, 8, 8, 9, 10, 11, 12, 13
953 },
954 {
955 8, 8, 8, 8, 9, 10, 11, 12
956 },
957 {
958 8, 8, 8, 8, 8, 9, 10, 11
959 },
960 {
961 8, 8, 8, 8, 8, 8, 9, 10
962 },
963 {
964 8, 8, 8, 8, 8, 8, 8, 9
965 },
966 {
967 8, 8, 8, 8, 8, 8, 8, 8
968 }
969 },
970 {
971 {
972 0, 0, 0, 0, 0, 0, 0, 0
973 },
974 {
975 0, 0, 0, 0, 0, 0, 0, 1
976 },
977 {
978 0, 0, 0, 0, 0, 0, 1, 2
979 },
980 {
981 0, 0, 0, 0, 0, 1, 2, 3
982 },
983 {
984 0, 0, 0, 0, 1, 2, 3, 4
985 },
986 {
987 0, 0, 0, 1, 2, 3, 4, 5
988 },
989 {
990 0, 0, 1, 2, 3, 4, 5, 6
991 },
992 {
993 0, 1, 2, 3, 4, 5, 6, 7
994 },
995 {
996 1, 2, 3, 4, 5, 6, 7, 8
997 },
998 {
999 2, 3, 4, 5, 6, 7, 8, 8
1000 },
1001 {
1002 3, 4, 5, 6, 7, 8, 8, 8
1003 },
1004 {
1005 4, 5, 6, 7, 8, 8, 8, 8
1006 },
1007 {
1008 5, 6, 7, 8, 8, 8, 8, 8
1009 },
1010 {
1011 6, 7, 8, 8, 8, 8, 8, 8
1012 },
1013 {
1014 7, 8, 8, 8, 8, 8, 8, 8
1015 },
1016 {
1017 8, 8, 8, 8, 8, 8, 8, 8
1018 }
1019 },
1020 {
1021 {
1022 0, 0, 0, 0, 0, 0, 0, 0
1023 },
1024 {
1025 0, 0, 0, 0, 0, 0, 0, 15
1026 },
1027 {
1028 0, 0, 0, 0, 0, 0, 15, 14
1029 },
1030 {
1031 0, 0, 0, 0, 0, 15, 14, 13
1032 },
1033 {
1034 0, 0, 0, 0, 15, 14, 13, 12
1035 },
1036 {
1037 0, 0, 0, 15, 14, 13, 12, 11
1038 },
1039 {
1040 0, 0, 15, 14, 13, 12, 11, 10
1041 },
1042 {
1043 0, 15, 14, 13, 12, 11, 10, 9
1044 },
1045 {
1046 15, 14, 13, 12, 11, 10, 9, 8
1047 },
1048 {
1049 14, 13, 12, 11, 10, 9, 8, 8
1050 },
1051 {
1052 13, 12, 11, 10, 9, 8, 8, 8
1053 },
1054 {
1055 12, 11, 10, 9, 8, 8, 8, 8
1056 },
1057 {
1058 11, 10, 9, 8, 8, 8, 8, 8
1059 },
1060 {
1061 10, 9, 8, 8, 8, 8, 8, 8
1062 },
1063 {
1064 9, 8, 8, 8, 8, 8, 8, 8
1065 },
1066 {
1067 8, 8, 8, 8, 8, 8, 8, 8
1068 }
1069 }
1070 };
1071 */
1072
1073
1074
1075 /*
1076 for (int32_t blockrow=0; blockrow<30; ++i)
1077 {
1078 for (int32_t linerow=0; linerow<8; ++i)
1079 {
1080 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
1081 for (int32_t blockcolumn=0; blockcolumn<40; ++i)
1082 {
1083 triangleline=triangles[0][screen_triangles[blockrow][blockcolumn]][linerow];
1084 ++triangleline;
1085 }
1086 }
1087 }
1088 */
1089
1090 // the ULL suffixes are to prevent this warning:
1091 // warning: integer constant is too large for "int32_t" type
1092
1093 qword triangles[4][16][8]= //[direction][value][line]
1094 {
1095 {
1096 {
1097 0x0000000000000000ULL,
1098 0x0000000000000000ULL,
1099 0x0000000000000000ULL,
1100 0x0000000000000000ULL,
1101 0x0000000000000000ULL,
1102 0x0000000000000000ULL,
1103 0x0000000000000000ULL,
1104 0x0000000000000000ULL
1105 },
1106 {
1107 0xFD00000000000000ULL,
1108 0x0000000000000000ULL,
1109 0x0000000000000000ULL,
1110 0x0000000000000000ULL,
1111 0x0000000000000000ULL,
1112 0x0000000000000000ULL,
1113 0x0000000000000000ULL,
1114 0x0000000000000000ULL
1115 },
1116 {
1117 0xFDFD000000000000ULL,
1118 0xFD00000000000000ULL,
1119 0x0000000000000000ULL,
1120 0x0000000000000000ULL,
1121 0x0000000000000000ULL,
1122 0x0000000000000000ULL,
1123 0x0000000000000000ULL,
1124 0x0000000000000000ULL
1125 },
1126 {
1127 0xFDFDFD0000000000ULL,
1128 0xFDFD000000000000ULL,
1129 0xFD00000000000000ULL,
1130 0x0000000000000000ULL,
1131 0x0000000000000000ULL,
1132 0x0000000000000000ULL,
1133 0x0000000000000000ULL,
1134 0x0000000000000000ULL
1135 },
1136 {
1137 0xFDFDFDFD00000000ULL,
1138 0xFDFDFD0000000000ULL,
1139 0xFDFD000000000000ULL,
1140 0xFD00000000000000ULL,
1141 0x0000000000000000ULL,
1142 0x0000000000000000ULL,
1143 0x0000000000000000ULL,
1144 0x0000000000000000ULL
1145 },
1146 {
1147 0xFDFDFDFDFD000000ULL,
1148 0xFDFDFDFD00000000ULL,
1149 0xFDFDFD0000000000ULL,
1150 0xFDFD000000000000ULL,
1151 0xFD00000000000000ULL,
1152 0x0000000000000000ULL,
1153 0x0000000000000000ULL,
1154 0x0000000000000000ULL
1155 },
1156 {
1157 0xFDFDFDFDFDFD0000ULL,
1158 0xFDFDFDFDFD000000ULL,
1159 0xFDFDFDFD00000000ULL,
1160 0xFDFDFD0000000000ULL,
1161 0xFDFD000000000000ULL,
1162 0xFD00000000000000ULL,
1163 0x0000000000000000ULL,
1164 0x0000000000000000ULL
1165 },
1166 {
1167 0xFDFDFDFDFDFDFD00ULL,
1168 0xFDFDFDFDFDFD0000ULL,
1169 0xFDFDFDFDFD000000ULL,
1170 0xFDFDFDFD00000000ULL,
1171 0xFDFDFD0000000000ULL,
1172 0xFDFD000000000000ULL,
1173 0xFD00000000000000ULL,
1174 0x0000000000000000ULL
1175 },
1176 {
1177 0xFDFDFDFDFDFDFDFDULL,
1178 0xFDFDFDFDFDFDFD00ULL,
1179 0xFDFDFDFDFDFD0000ULL,
1180 0xFDFDFDFDFD000000ULL,
1181 0xFDFDFDFD00000000ULL,
1182 0xFDFDFD0000000000ULL,
1183 0xFDFD000000000000ULL,
1184 0xFD00000000000000ULL
1185 },
1186 {
1187 0xFDFDFDFDFDFDFDFDULL,
1188 0xFDFDFDFDFDFDFDFDULL,
1189 0xFDFDFDFDFDFDFD00ULL,
1190 0xFDFDFDFDFDFD0000ULL,
1191 0xFDFDFDFDFD000000ULL,
1192 0xFDFDFDFD00000000ULL,
1193 0xFDFDFD0000000000ULL,
1194 0xFDFD000000000000ULL
1195 },
1196 {
1197 0xFDFDFDFDFDFDFDFDULL,
1198 0xFDFDFDFDFDFDFDFDULL,
1199 0xFDFDFDFDFDFDFDFDULL,
1200 0xFDFDFDFDFDFDFD00ULL,
1201 0xFDFDFDFDFDFD0000ULL,
1202 0xFDFDFDFDFD000000ULL,
1203 0xFDFDFDFD00000000ULL,
1204 0xFDFDFD0000000000ULL
1205 },
1206 {
1207 0xFDFDFDFDFDFDFDFDULL,
1208 0xFDFDFDFDFDFDFDFDULL,
1209 0xFDFDFDFDFDFDFDFDULL,
1210 0xFDFDFDFDFDFDFDFDULL,
1211 0xFDFDFDFDFDFDFD00ULL,
1212 0xFDFDFDFDFDFD0000ULL,
1213 0xFDFDFDFDFD000000ULL,
1214 0xFDFDFDFD00000000ULL
1215 },
1216 {
1217 0xFDFDFDFDFDFDFDFDULL,
1218 0xFDFDFDFDFDFDFDFDULL,
1219 0xFDFDFDFDFDFDFDFDULL,
1220 0xFDFDFDFDFDFDFDFDULL,
1221 0xFDFDFDFDFDFDFDFDULL,
1222 0xFDFDFDFDFDFDFD00ULL,
1223 0xFDFDFDFDFDFD0000ULL,
1224 0xFDFDFDFDFD000000ULL
1225 },
1226 {
1227 0xFDFDFDFDFDFDFDFDULL,
1228 0xFDFDFDFDFDFDFDFDULL,
1229 0xFDFDFDFDFDFDFDFDULL,
1230 0xFDFDFDFDFDFDFDFDULL,
1231 0xFDFDFDFDFDFDFDFDULL,
1232 0xFDFDFDFDFDFDFDFDULL,
1233 0xFDFDFDFDFDFDFD00ULL,
1234 0xFDFDFDFDFDFD0000ULL
1235 },
1236 {
1237 0xFDFDFDFDFDFDFDFDULL,
1238 0xFDFDFDFDFDFDFDFDULL,
1239 0xFDFDFDFDFDFDFDFDULL,
1240 0xFDFDFDFDFDFDFDFDULL,
1241 0xFDFDFDFDFDFDFDFDULL,
1242 0xFDFDFDFDFDFDFDFDULL,
1243 0xFDFDFDFDFDFDFDFDULL,
1244 0xFDFDFDFDFDFDFD00ULL
1245 },
1246 {
1247 0xFDFDFDFDFDFDFDFDULL,
1248 0xFDFDFDFDFDFDFDFDULL,
1249 0xFDFDFDFDFDFDFDFDULL,
1250 0xFDFDFDFDFDFDFDFDULL,
1251 0xFDFDFDFDFDFDFDFDULL,
1252 0xFDFDFDFDFDFDFDFDULL,
1253 0xFDFDFDFDFDFDFDFDULL,
1254 0xFDFDFDFDFDFDFDFDULL
1255 }
1256 },
1257 {
1258 {
1259 0x0000000000000000ULL,
1260 0x0000000000000000ULL,
1261 0x0000000000000000ULL,
1262 0x0000000000000000ULL,
1263 0x0000000000000000ULL,
1264 0x0000000000000000ULL,
1265 0x0000000000000000ULL,
1266 0x0000000000000000ULL
1267 },
1268 {
1269 0x00000000000000FDULL,
1270 0x0000000000000000ULL,
1271 0x0000000000000000ULL,
1272 0x0000000000000000ULL,
1273 0x0000000000000000ULL,
1274 0x0000000000000000ULL,
1275 0x0000000000000000ULL,
1276 0x0000000000000000ULL
1277 },
1278 {
1279 0x000000000000FDFDULL,
1280 0x00000000000000FDULL,
1281 0x0000000000000000ULL,
1282 0x0000000000000000ULL,
1283 0x0000000000000000ULL,
1284 0x0000000000000000ULL,
1285 0x0000000000000000ULL,
1286 0x0000000000000000ULL
1287 },
1288 {
1289 0x0000000000FDFDFDULL,
1290 0x000000000000FDFDULL,
1291 0x00000000000000FDULL,
1292 0x0000000000000000ULL,
1293 0x0000000000000000ULL,
1294 0x0000000000000000ULL,
1295 0x0000000000000000ULL,
1296 0x0000000000000000ULL
1297 },
1298 {
1299 0x00000000FDFDFDFDULL,
1300 0x0000000000FDFDFDULL,
1301 0x000000000000FDFDULL,
1302 0x00000000000000FDULL,
1303 0x0000000000000000ULL,
1304 0x0000000000000000ULL,
1305 0x0000000000000000ULL,
1306 0x0000000000000000ULL
1307 },
1308 {
1309 0x000000FDFDFDFDFDULL,
1310 0x00000000FDFDFDFDULL,
1311 0x0000000000FDFDFDULL,
1312 0x000000000000FDFDULL,
1313 0x00000000000000FDULL,
1314 0x0000000000000000ULL,
1315 0x0000000000000000ULL,
1316 0x0000000000000000ULL
1317 },
1318 {
1319 0x0000FDFDFDFDFDFDULL,
1320 0x000000FDFDFDFDFDULL,
1321 0x00000000FDFDFDFDULL,
1322 0x0000000000FDFDFDULL,
1323 0x000000000000FDFDULL,
1324 0x00000000000000FDULL,
1325 0x0000000000000000ULL,
1326 0x0000000000000000ULL
1327 },
1328 {
1329 0x00FDFDFDFDFDFDFDULL,
1330 0x0000FDFDFDFDFDFDULL,
1331 0x000000FDFDFDFDFDULL,
1332 0x00000000FDFDFDFDULL,
1333 0x0000000000FDFDFDULL,
1334 0x000000000000FDFDULL,
1335 0x00000000000000FDULL,
1336 0x0000000000000000ULL
1337 },
1338 {
1339 0xFDFDFDFDFDFDFDFDULL,
1340 0x00FDFDFDFDFDFDFDULL,
1341 0x0000FDFDFDFDFDFDULL,
1342 0x000000FDFDFDFDFDULL,
1343 0x00000000FDFDFDFDULL,
1344 0x0000000000FDFDFDULL,
1345 0x000000000000FDFDULL,
1346 0x00000000000000FDULL
1347 },
1348 {
1349 0xFDFDFDFDFDFDFDFDULL,
1350 0xFDFDFDFDFDFDFDFDULL,
1351 0x00FDFDFDFDFDFDFDULL,
1352 0x0000FDFDFDFDFDFDULL,
1353 0x000000FDFDFDFDFDULL,
1354 0x00000000FDFDFDFDULL,
1355 0x0000000000FDFDFDULL,
1356 0x000000000000FDFDULL
1357 },
1358 {
1359 0xFDFDFDFDFDFDFDFDULL,
1360 0xFDFDFDFDFDFDFDFDULL,
1361 0xFDFDFDFDFDFDFDFDULL,
1362 0x00FDFDFDFDFDFDFDULL,
1363 0x0000FDFDFDFDFDFDULL,
1364 0x000000FDFDFDFDFDULL,
1365 0x00000000FDFDFDFDULL,
1366 0x0000000000FDFDFDULL
1367 },
1368 {
1369 0xFDFDFDFDFDFDFDFDULL,
1370 0xFDFDFDFDFDFDFDFDULL,
1371 0xFDFDFDFDFDFDFDFDULL,
1372 0xFDFDFDFDFDFDFDFDULL,
1373 0x00FDFDFDFDFDFDFDULL,
1374 0x0000FDFDFDFDFDFDULL,
1375 0x000000FDFDFDFDFDULL,
1376 0x00000000FDFDFDFDULL
1377 },
1378 {
1379 0xFDFDFDFDFDFDFDFDULL,
1380 0xFDFDFDFDFDFDFDFDULL,
1381 0xFDFDFDFDFDFDFDFDULL,
1382 0xFDFDFDFDFDFDFDFDULL,
1383 0xFDFDFDFDFDFDFDFDULL,
1384 0x00FDFDFDFDFDFDFDULL,
1385 0x0000FDFDFDFDFDFDULL,
1386 0x000000FDFDFDFDFDULL
1387 },
1388 {
1389 0xFDFDFDFDFDFDFDFDULL,
1390 0xFDFDFDFDFDFDFDFDULL,
1391 0xFDFDFDFDFDFDFDFDULL,
1392 0xFDFDFDFDFDFDFDFDULL,
1393 0xFDFDFDFDFDFDFDFDULL,
1394 0xFDFDFDFDFDFDFDFDULL,
1395 0x00FDFDFDFDFDFDFDULL,
1396 0x0000FDFDFDFDFDFDULL
1397 },
1398 {
1399 0xFDFDFDFDFDFDFDFDULL,
1400 0xFDFDFDFDFDFDFDFDULL,
1401 0xFDFDFDFDFDFDFDFDULL,
1402 0xFDFDFDFDFDFDFDFDULL,
1403 0xFDFDFDFDFDFDFDFDULL,
1404 0xFDFDFDFDFDFDFDFDULL,
1405 0xFDFDFDFDFDFDFDFDULL,
1406 0x00FDFDFDFDFDFDFDULL
1407 },
1408 {
1409 0xFDFDFDFDFDFDFDFDULL,
1410 0xFDFDFDFDFDFDFDFDULL,
1411 0xFDFDFDFDFDFDFDFDULL,
1412 0xFDFDFDFDFDFDFDFDULL,
1413 0xFDFDFDFDFDFDFDFDULL,
1414 0xFDFDFDFDFDFDFDFDULL,
1415 0xFDFDFDFDFDFDFDFDULL,
1416 0xFDFDFDFDFDFDFDFDULL
1417 }
1418 },
1419 {
1420 {
1421 0x0000000000000000ULL,
1422 0x0000000000000000ULL,
1423 0x0000000000000000ULL,
1424 0x0000000000000000ULL,
1425 0x0000000000000000ULL,
1426 0x0000000000000000ULL,
1427 0x0000000000000000ULL,
1428 0x0000000000000000ULL
1429 },
1430 {
1431 0x0000000000000000ULL,
1432 0x0000000000000000ULL,
1433 0x0000000000000000ULL,
1434 0x0000000000000000ULL,
1435 0x0000000000000000ULL,
1436 0x0000000000000000ULL,
1437 0x0000000000000000ULL,
1438 0xFD00000000000000ULL
1439 },
1440 {
1441 0x0000000000000000ULL,
1442 0x0000000000000000ULL,
1443 0x0000000000000000ULL,
1444 0x0000000000000000ULL,
1445 0x0000000000000000ULL,
1446 0x0000000000000000ULL,
1447 0xFD00000000000000ULL,
1448 0xFDFD000000000000ULL
1449 },
1450 {
1451 0x0000000000000000ULL,
1452 0x0000000000000000ULL,
1453 0x0000000000000000ULL,
1454 0x0000000000000000ULL,
1455 0x0000000000000000ULL,
1456 0xFD00000000000000ULL,
1457 0xFDFD000000000000ULL,
1458 0xFDFDFD0000000000ULL
1459 },
1460 {
1461 0x0000000000000000ULL,
1462 0x0000000000000000ULL,
1463 0x0000000000000000ULL,
1464 0x0000000000000000ULL,
1465 0xFD00000000000000ULL,
1466 0xFDFD000000000000ULL,
1467 0xFDFDFD0000000000ULL,
1468 0xFDFDFDFD00000000ULL
1469 },
1470 {
1471 0x0000000000000000ULL,
1472 0x0000000000000000ULL,
1473 0x0000000000000000ULL,
1474 0xFD00000000000000ULL,
1475 0xFDFD000000000000ULL,
1476 0xFDFDFD0000000000ULL,
1477 0xFDFDFDFD00000000ULL,
1478 0xFDFDFDFDFD000000ULL
1479 },
1480 {
1481 0x0000000000000000ULL,
1482 0x0000000000000000ULL,
1483 0xFD00000000000000ULL,
1484 0xFDFD000000000000ULL,
1485 0xFDFDFD0000000000ULL,
1486 0xFDFDFDFD00000000ULL,
1487 0xFDFDFDFDFD000000ULL,
1488 0xFDFDFDFDFDFD0000ULL
1489 },
1490 {
1491 0x0000000000000000ULL,
1492 0xFD00000000000000ULL,
1493 0xFDFD000000000000ULL,
1494 0xFDFDFD0000000000ULL,
1495 0xFDFDFDFD00000000ULL,
1496 0xFDFDFDFDFD000000ULL,
1497 0xFDFDFDFDFDFD0000ULL,
1498 0xFDFDFDFDFDFDFD00ULL
1499 },
1500 {
1501 0xFD00000000000000ULL,
1502 0xFDFD000000000000ULL,
1503 0xFDFDFD0000000000ULL,
1504 0xFDFDFDFD00000000ULL,
1505 0xFDFDFDFDFD000000ULL,
1506 0xFDFDFDFDFDFD0000ULL,
1507 0xFDFDFDFDFDFDFD00ULL,
1508 0xFDFDFDFDFDFDFDFDULL
1509 },
1510 {
1511 0xFDFD000000000000ULL,
1512 0xFDFDFD0000000000ULL,
1513 0xFDFDFDFD00000000ULL,
1514 0xFDFDFDFDFD000000ULL,
1515 0xFDFDFDFDFDFD0000ULL,
1516 0xFDFDFDFDFDFDFD00ULL,
1517 0xFDFDFDFDFDFDFDFDULL,
1518 0xFDFDFDFDFDFDFDFDULL
1519 },
1520 {
1521 0xFDFDFD0000000000ULL,
1522 0xFDFDFDFD00000000ULL,
1523 0xFDFDFDFDFD000000ULL,
1524 0xFDFDFDFDFDFD0000ULL,
1525 0xFDFDFDFDFDFDFD00ULL,
1526 0xFDFDFDFDFDFDFDFDULL,
1527 0xFDFDFDFDFDFDFDFDULL,
1528 0xFDFDFDFDFDFDFDFDULL
1529 },
1530 {
1531 0xFDFDFDFD00000000ULL,
1532 0xFDFDFDFDFD000000ULL,
1533 0xFDFDFDFDFDFD0000ULL,
1534 0xFDFDFDFDFDFDFD00ULL,
1535 0xFDFDFDFDFDFDFDFDULL,
1536 0xFDFDFDFDFDFDFDFDULL,
1537 0xFDFDFDFDFDFDFDFDULL,
1538 0xFDFDFDFDFDFDFDFDULL
1539 },
1540 {
1541 0xFDFDFDFDFD000000ULL,
1542 0xFDFDFDFDFDFD0000ULL,
1543 0xFDFDFDFDFDFDFD00ULL,
1544 0xFDFDFDFDFDFDFDFDULL,
1545 0xFDFDFDFDFDFDFDFDULL,
1546 0xFDFDFDFDFDFDFDFDULL,
1547 0xFDFDFDFDFDFDFDFDULL,
1548 0xFDFDFDFDFDFDFDFDULL
1549 },
1550 {
1551 0xFDFDFDFDFDFD0000ULL,
1552 0xFDFDFDFDFDFDFD00ULL,
1553 0xFDFDFDFDFDFDFDFDULL,
1554 0xFDFDFDFDFDFDFDFDULL,
1555 0xFDFDFDFDFDFDFDFDULL,
1556 0xFDFDFDFDFDFDFDFDULL,
1557 0xFDFDFDFDFDFDFDFDULL,
1558 0xFDFDFDFDFDFDFDFDULL
1559 },
1560 {
1561 0xFDFDFDFDFDFDFD00ULL,
1562 0xFDFDFDFDFDFDFDFDULL,
1563 0xFDFDFDFDFDFDFDFDULL,
1564 0xFDFDFDFDFDFDFDFDULL,
1565 0xFDFDFDFDFDFDFDFDULL,
1566 0xFDFDFDFDFDFDFDFDULL,
1567 0xFDFDFDFDFDFDFDFDULL,
1568 0xFDFDFDFDFDFDFDFDULL
1569 },
1570 {
1571 0xFDFDFDFDFDFDFDFDULL,
1572 0xFDFDFDFDFDFDFDFDULL,
1573 0xFDFDFDFDFDFDFDFDULL,
1574 0xFDFDFDFDFDFDFDFDULL,
1575 0xFDFDFDFDFDFDFDFDULL,
1576 0xFDFDFDFDFDFDFDFDULL,
1577 0xFDFDFDFDFDFDFDFDULL,
1578 0xFDFDFDFDFDFDFDFDULL
1579 }
1580 },
1581 {
1582 {
1583 0x0000000000000000ULL,
1584 0x0000000000000000ULL,
1585 0x0000000000000000ULL,
1586 0x0000000000000000ULL,
1587 0x0000000000000000ULL,
1588 0x0000000000000000ULL,
1589 0x0000000000000000ULL,
1590 0x0000000000000000ULL
1591 },
1592 {
1593 0x0000000000000000ULL,
1594 0x0000000000000000ULL,
1595 0x0000000000000000ULL,
1596 0x0000000000000000ULL,
1597 0x0000000000000000ULL,
1598 0x0000000000000000ULL,
1599 0x0000000000000000ULL,
1600 0x00000000000000FDULL
1601 },
1602 {
1603 0x0000000000000000ULL,
1604 0x0000000000000000ULL,
1605 0x0000000000000000ULL,
1606 0x0000000000000000ULL,
1607 0x0000000000000000ULL,
1608 0x0000000000000000ULL,
1609 0x00000000000000FDULL,
1610 0x000000000000FDFDULL
1611 },
1612 {
1613 0x0000000000000000ULL,
1614 0x0000000000000000ULL,
1615 0x0000000000000000ULL,
1616 0x0000000000000000ULL,
1617 0x0000000000000000ULL,
1618 0x00000000000000FDULL,
1619 0x000000000000FDFDULL,
1620 0x0000000000FDFDFDULL
1621 },
1622 {
1623 0x0000000000000000ULL,
1624 0x0000000000000000ULL,
1625 0x0000000000000000ULL,
1626 0x0000000000000000ULL,
1627 0x00000000000000FDULL,
1628 0x000000000000FDFDULL,
1629 0x0000000000FDFDFDULL,
1630 0x00000000FDFDFDFDULL
1631 },
1632 {
1633 0x0000000000000000ULL,
1634 0x0000000000000000ULL,
1635 0x0000000000000000ULL,
1636 0x00000000000000FDULL,
1637 0x000000000000FDFDULL,
1638 0x0000000000FDFDFDULL,
1639 0x00000000FDFDFDFDULL,
1640 0x000000FDFDFDFDFDULL
1641 },
1642 {
1643 0x0000000000000000ULL,
1644 0x0000000000000000ULL,
1645 0x00000000000000FDULL,
1646 0x000000000000FDFDULL,
1647 0x0000000000FDFDFDULL,
1648 0x00000000FDFDFDFDULL,
1649 0x000000FDFDFDFDFDULL,
1650 0x0000FDFDFDFDFDFDULL
1651 },
1652 {
1653 0x0000000000000000ULL,
1654 0x00000000000000FDULL,
1655 0x000000000000FDFDULL,
1656 0x0000000000FDFDFDULL,
1657 0x00000000FDFDFDFDULL,
1658 0x000000FDFDFDFDFDULL,
1659 0x0000FDFDFDFDFDFDULL,
1660 0x00FDFDFDFDFDFDFDULL
1661 },
1662 {
1663 0x00000000000000FDULL,
1664 0x000000000000FDFDULL,
1665 0x0000000000FDFDFDULL,
1666 0x00000000FDFDFDFDULL,
1667 0x000000FDFDFDFDFDULL,
1668 0x0000FDFDFDFDFDFDULL,
1669 0x00FDFDFDFDFDFDFDULL,
1670 0xFDFDFDFDFDFDFDFDULL
1671 },
1672 {
1673 0x000000000000FDFDULL,
1674 0x0000000000FDFDFDULL,
1675 0x00000000FDFDFDFDULL,
1676 0x000000FDFDFDFDFDULL,
1677 0x0000FDFDFDFDFDFDULL,
1678 0x00FDFDFDFDFDFDFDULL,
1679 0xFDFDFDFDFDFDFDFDULL,
1680 0xFDFDFDFDFDFDFDFDULL
1681 },
1682 {
1683 0x0000000000FDFDFDULL,
1684 0x00000000FDFDFDFDULL,
1685 0x000000FDFDFDFDFDULL,
1686 0x0000FDFDFDFDFDFDULL,
1687 0x00FDFDFDFDFDFDFDULL,
1688 0xFDFDFDFDFDFDFDFDULL,
1689 0xFDFDFDFDFDFDFDFDULL,
1690 0xFDFDFDFDFDFDFDFDULL
1691 },
1692 {
1693 0x00000000FDFDFDFDULL,
1694 0x000000FDFDFDFDFDULL,
1695 0x0000FDFDFDFDFDFDULL,
1696 0x00FDFDFDFDFDFDFDULL,
1697 0xFDFDFDFDFDFDFDFDULL,
1698 0xFDFDFDFDFDFDFDFDULL,
1699 0xFDFDFDFDFDFDFDFDULL,
1700 0xFDFDFDFDFDFDFDFDULL
1701 },
1702 {
1703 0x000000FDFDFDFDFDULL,
1704 0x0000FDFDFDFDFDFDULL,
1705 0x00FDFDFDFDFDFDFDULL,
1706 0xFDFDFDFDFDFDFDFDULL,
1707 0xFDFDFDFDFDFDFDFDULL,
1708 0xFDFDFDFDFDFDFDFDULL,
1709 0xFDFDFDFDFDFDFDFDULL,
1710 0xFDFDFDFDFDFDFDFDULL
1711 },
1712 {
1713 0x0000FDFDFDFDFDFDULL,
1714 0x00FDFDFDFDFDFDFDULL,
1715 0xFDFDFDFDFDFDFDFDULL,
1716 0xFDFDFDFDFDFDFDFDULL,
1717 0xFDFDFDFDFDFDFDFDULL,
1718 0xFDFDFDFDFDFDFDFDULL,
1719 0xFDFDFDFDFDFDFDFDULL,
1720 0xFDFDFDFDFDFDFDFDULL
1721 },
1722 {
1723 0x00FDFDFDFDFDFDFDULL,
1724 0xFDFDFDFDFDFDFDFDULL,
1725 0xFDFDFDFDFDFDFDFDULL,
1726 0xFDFDFDFDFDFDFDFDULL,
1727 0xFDFDFDFDFDFDFDFDULL,
1728 0xFDFDFDFDFDFDFDFDULL,
1729 0xFDFDFDFDFDFDFDFDULL,
1730 0xFDFDFDFDFDFDFDFDULL
1731 },
1732 {
1733 0xFDFDFDFDFDFDFDFDULL,
1734 0xFDFDFDFDFDFDFDFDULL,
1735 0xFDFDFDFDFDFDFDFDULL,
1736 0xFDFDFDFDFDFDFDFDULL,
1737 0xFDFDFDFDFDFDFDFDULL,
1738 0xFDFDFDFDFDFDFDFDULL,
1739 0xFDFDFDFDFDFDFDFDULL,
1740 0xFDFDFDFDFDFDFDFDULL
1741 }
1742 }
1743 };
1744
1745 int32_t black_opening_count=0;
1746 int32_t black_opening_x,black_opening_y;
1747 int32_t black_opening_shape;
1748
1749 1505 int32_t choose_opening_shape()
1750 {
1751 // First, count how many bits are set
1752 1505 int32_t numBits=0;
1753 int32_t bitCounter;
1754
1755
2/2
✓ Branch 0 taken 7525 times.
✓ Branch 1 taken 1505 times.
9030 for(int32_t i=0; i<bosMAX; i++)
1756 {
1757
2/2
✓ Branch 0 taken 5804 times.
✓ Branch 1 taken 1721 times.
7525 if(COOLSCROLL&(1<<i))
1758 1721 numBits++;
1759 7525 }
1760
1761 // Shouldn't happen...
1762
1/2
✓ Branch 0 taken 1505 times.
✗ Branch 1 not taken.
1505 if(numBits==0)
1763 return bosCIRCLE;
1764
1765 // Pick a bit
1766 1505 bitCounter=zc_rand()%numBits+1;
1767
1768
2/2
✓ Branch 0 taken 1988 times.
✓ Branch 1 taken 26 times.
2014 for(int32_t i=0; i<bosMAX; i++)
1769 {
1770 // If this bit is set, decrement the bit counter
1771
2/2
✓ Branch 0 taken 353 times.
✓ Branch 1 taken 1635 times.
1988 if(COOLSCROLL&(1<<i))
1772 1635 bitCounter--;
1773
1774 // When the counter hits 0, return a value based on
1775 // which bit it stopped on.
1776 // Reminder: enum {bosCIRCLE=0, bosOVAL, bosTRIANGLE, bosSMAS, bosFADEBLACK, bosMAX};
1777
2/2
✓ Branch 0 taken 1479 times.
✓ Branch 1 taken 509 times.
1988 if(bitCounter==0)
1778 1479 return i;
1779 509 }
1780
1781 // Shouldn't be necessary, but the compiler might complain, at least
1782 26 return bosCIRCLE;
1783 1505 }
1784
1785 396 void close_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1786 {
1787
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 396 times.
396 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1788
1789 396 int32_t w=256, h=224;
1790 396 int32_t blockrows=28, blockcolumns=32;
1791 396 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1792
1793
2/2
✓ Branch 0 taken 11088 times.
✓ Branch 1 taken 396 times.
11484 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1794 {
1795
2/2
✓ Branch 0 taken 354816 times.
✓ Branch 1 taken 11088 times.
365904 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1796 {
1797
2/2
✓ Branch 0 taken 188540 times.
✓ Branch 1 taken 166276 times.
354816 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1798 354816 }
1799 11088 }
1800
1801 396 black_opening_count = 66;
1802 396 black_opening_x = x;
1803 396 black_opening_y = y;
1804 396 lensclk = 0;
1805 //black_opening_shape=(black_opening_shape+1)%bosMAX;
1806
1807
1808
1/2
✓ Branch 0 taken 396 times.
✗ Branch 1 not taken.
396 if(black_opening_shape == bosFADEBLACK)
1809 {
1810 refreshTints();
1811 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1812 }
1813
1/2
✓ Branch 0 taken 396 times.
✗ Branch 1 not taken.
396 if(wait)
1814 {
1815 FFCore.warpScriptCheck();
1816 for(int32_t i=0; i<66; i++)
1817 {
1818 draw_screen(tmpscr);
1819 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
1820 advanceframe(true);
1821
1822 if(Quit)
1823 {
1824 break;
1825 }
1826 }
1827 }
1828 396 }
1829
1830 1109 void open_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1831 {
1832
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1109 times.
1109 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1833
1834 1109 int32_t w=256, h=224;
1835 1109 int32_t blockrows=28, blockcolumns=32;
1836 1109 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1837
1838
2/2
✓ Branch 0 taken 31052 times.
✓ Branch 1 taken 1109 times.
32161 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1839 {
1840
2/2
✓ Branch 0 taken 993664 times.
✓ Branch 1 taken 31052 times.
1024716 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1841 {
1842
2/2
✓ Branch 0 taken 441984 times.
✓ Branch 1 taken 551680 times.
993664 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1843 993664 }
1844 31052 }
1845
1846 1109 black_opening_count = -66;
1847 1109 black_opening_x = x;
1848 1109 black_opening_y = y;
1849 1109 lensclk = 0;
1850
1/2
✓ Branch 0 taken 1109 times.
✗ Branch 1 not taken.
1109 if(black_opening_shape == bosFADEBLACK)
1851 {
1852 refreshTints();
1853 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1854 }
1855
2/2
✓ Branch 0 taken 199 times.
✓ Branch 1 taken 910 times.
1109 if(wait)
1856 {
1857 910 FFCore.warpScriptCheck();
1858
2/2
✓ Branch 0 taken 910 times.
✓ Branch 1 taken 60060 times.
60970 for(int32_t i=0; i<66; i++)
1859 {
1860 60060 draw_screen(tmpscr);
1861 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
1862 60060 advanceframe(true);
1863
1864
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60060 times.
60060 if(Quit)
1865 {
1866 break;
1867 }
1868 60060 }
1869 910 }
1870 1109 }
1871
1872 99330 void black_opening(BITMAP *dest,int32_t x,int32_t y,int32_t a,int32_t max_a)
1873 {
1874 99330 clear_to_color(tmp_scr,BLACK);
1875 99330 int32_t w=256, h=224;
1876
1877
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 858 times.
✓ Branch 2 taken 594 times.
✓ Branch 3 taken 7656 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 90222 times.
99330 switch(black_opening_shape)
1878 {
1879 case bosOVAL:
1880 {
1881 858 double new_w=(w/2)+abs(w/2-x);
1882 858 double new_h=(h/2)+abs(h/2-y);
1883 858 double b=sqrt(((new_w*new_w)/4)+(new_h*new_h));
1884 858 ellipsefill(tmp_scr,x,y,int32_t(2*a*b/max_a)/8*8,int32_t(a*b/max_a)/8*8,0);
1885 858 break;
1886 }
1887
1888 case bosTRIANGLE:
1889 {
1890 594 double new_w=(w/2)+abs(w/2-x);
1891 594 double new_h=(h/2)+abs(h/2-y);
1892 594 double r=a*(new_w*sqrt((double)3)+new_h)/max_a;
1893 594 double P2= (PI/2);
1894 594 double P23=(2*PI/3);
1895 594 double P43=(4*PI/3);
1896 594 double Pa= (-4*PI*a/(3*max_a));
1897 594 double angle=P2+Pa;
1898 594 double a0=angle;
1899 594 double a2=angle+P23;
1900 594 double a4=angle+P43;
1901 1188 triangle(tmp_scr, x+int32_t(zc::math::Cos(a0)*r), y-int32_t(zc::math::Sin(a0)*r),
1902 594 x+int32_t(zc::math::Cos(a2)*r), y-int32_t(zc::math::Sin(a2)*r),
1903 594 x+int32_t(zc::math::Cos(a4)*r), y-int32_t(zc::math::Sin(a4)*r),
1904 0);
1905 594 break;
1906 }
1907
1908 case bosSMAS:
1909 {
1910
2/2
✓ Branch 0 taken 2838 times.
✓ Branch 1 taken 4818 times.
7656 int32_t distance=zc_max(abs(w/2-x),abs(h/2-y))/8;
1911
1912
2/2
✓ Branch 0 taken 214368 times.
✓ Branch 1 taken 7656 times.
222024 for(int32_t blockrow=0; blockrow<28; ++blockrow) //30
1913 {
1914
2/2
✓ Branch 0 taken 1714944 times.
✓ Branch 1 taken 214368 times.
1929312 for(int32_t linerow=0; linerow<8; ++linerow)
1915 {
1916 1714944 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
1917
1918
2/2
✓ Branch 0 taken 54878208 times.
✓ Branch 1 taken 1714944 times.
56593152 for(int32_t blockcolumn=0; blockcolumn<32; ++blockcolumn) //40
1919 {
1920 164634624 *triangleline=triangles[(screen_triangles[blockrow][blockcolumn]&0xC000)>>14]
1921
6/6
✓ Branch 0 taken 38180568 times.
✓ Branch 1 taken 16697640 times.
✓ Branch 2 taken 35934032 times.
✓ Branch 3 taken 18944176 times.
✓ Branch 4 taken 19236392 times.
✓ Branch 5 taken 16697640 times.
54878208 [zc_min(zc_max((((31+distance)*(max_a-a)/max_a)+((screen_triangles[blockrow][blockcolumn]&0x0FFF)-0x0100)-(15+distance)),0),15)]
1922 54878208 [linerow];
1923 54878208 ++triangleline;
1924
1925
2/2
✓ Branch 0 taken 48018432 times.
✓ Branch 1 taken 6859776 times.
54878208 if(linerow==0)
1926 {
1927 6859776 }
1928 54878208 }
1929 1714944 }
1930 214368 }
1931
1932 7656 break;
1933 }
1934
1935 case bosFADEBLACK:
1936 {
1937 if(black_opening_count<0)
1938 {
1939 black_fade(zc_min(-black_opening_count,63));
1940 }
1941 else if(black_opening_count>0)
1942 {
1943 black_fade(63-zc_max(black_opening_count-3,0));
1944 }
1945 else black_fade(0);
1946 return; //no blitting from tmp_scr!
1947 }
1948
1949 90222 case bosCIRCLE:
1950 default:
1951 {
1952 90222 double new_w=(w/2)+abs(w/2-x);
1953 90222 double new_h=(h/2)+abs(h/2-y);
1954 90222 int32_t r=int32_t(sqrt((new_w*new_w)+(new_h*new_h))*a/max_a);
1955 //circlefill(tmp_scr,x,y,a<<3,0);
1956 90222 circlefill(tmp_scr,x,y,r,0);
1957 90222 break;
1958 }
1959 }
1960
1961 99330 masked_blit(tmp_scr,dest,0,0,0,0,320,240);
1962 99330 }
1963
1964
1965 void black_fade(int32_t fadeamnt)
1966 {
1967 for(int32_t i=0; i < 0xEF; i++)
1968 {
1969 RAMpal[i].r = vbound(tempblackpal[i].r-fadeamnt,0,63);
1970 RAMpal[i].g = vbound(tempblackpal[i].g-fadeamnt,0,63);
1971 RAMpal[i].b = vbound(tempblackpal[i].b-fadeamnt,0,63);
1972 }
1973
1974 refreshpal = true;
1975 }
1976
1977 //----------------------------------------------------------------
1978
1979 44281530 bool item_disabled(int32_t item) //is this item disabled?
1980 {
1981
2/2
✓ Branch 0 taken 1737959 times.
✓ Branch 1 taken 42543571 times.
44281530 return (unsigned(item) < MAXITEMS && game->items_off[item] != 0);
1982 }
1983
1984 7616690 bool can_use_item(int32_t item_type, int32_t item) //can Hero use this item?
1985 {
1986
2/2
✓ Branch 0 taken 135210 times.
✓ Branch 1 taken 7481480 times.
7616690 if(current_item(item_type, true) >=item)
1987 {
1988 135210 return true;
1989 }
1990
1991 7481480 return false;
1992 7616690 }
1993
1994 31050372 bool has_item(int32_t item_type, int32_t it) //does Hero possess this item?
1995 {
1996
5/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 6052308 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3220277 times.
✓ Branch 6 taken 16168602 times.
✓ Branch 7 taken 5493498 times.
✓ Branch 8 taken 115687 times.
31050372 switch(item_type)
1997 {
1998 case itype_bomb:
1999 case itype_sbomb:
2000 {
2001 int32_t itemid = getItemID(itemsbuf, item_type, it);
2002
2003 if(itemid == -1)
2004 return false;
2005
2006 return (game->get_item(itemid));
2007 }
2008
2009 case itype_clock:
2010 {
2011 6052308 int32_t itemid = getItemID(itemsbuf, item_type, it);
2012
2013
2/4
✓ Branch 0 taken 6052308 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6052308 times.
✗ Branch 3 not taken.
6052308 if(itemid != -1 && (itemsbuf[itemid].flags & ITEM_FLAG1)) //Active clock
2014 return (game->get_item(itemid));
2015 6052308 return Hero.getClock()?1:0;
2016 }
2017
2018 case itype_key:
2019 return (game->get_keys()>0);
2020
2021 case itype_magiccontainer:
2022 return (game->get_maxmagic()>=game->get_mp_per_block());
2023
2024 case itype_triforcepiece: //it: -2=any, -1=current level, other=that level
2025 {
2026
1/3
✓ Branch 0 taken 3220277 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
3220277 switch(it)
2027 {
2028 case -2:
2029 {
2030 for(int32_t i=0; i<MAXLEVELS; i++)
2031 {
2032 if(game->lvlitems[i]&liTRIFORCE)
2033 {
2034 return true;
2035 }
2036 }
2037
2038 return false;
2039 }
2040
2041 case -1:
2042 return (game->lvlitems[dlevel]&liTRIFORCE);
2043
2044 default:
2045
2/4
✓ Branch 0 taken 3220277 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3220277 times.
3220277 if(it>=0&&it<MAXLEVELS)
2046 {
2047 3220277 return (game->lvlitems[it]&liTRIFORCE);
2048 }
2049
2050 break;
2051 }
2052
2053 return 0;
2054 }
2055
2056 case itype_map: //it: -2=any, -1=current level, other=that level
2057 {
2058
1/3
✓ Branch 0 taken 16168602 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
16168602 switch(it)
2059 {
2060 case -2:
2061 {
2062 for(int32_t i=0; i<MAXLEVELS; i++)
2063 {
2064 if(game->lvlitems[i]&liMAP)
2065 {
2066 return true;
2067 }
2068 }
2069
2070 return false;
2071 }
2072
2073 case -1:
2074 return (game->lvlitems[dlevel]&liMAP)!=0;
2075
2076 default:
2077
2/4
✓ Branch 0 taken 16168602 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 16168602 times.
16168602 if(it>=0&&it<MAXLEVELS)
2078 {
2079 16168602 return (game->lvlitems[it]&liMAP)!=0;
2080 }
2081
2082 break;
2083 }
2084
2085 return 0;
2086 }
2087
2088 case itype_compass: //it: -2=any, -1=current level, other=that level
2089 {
2090
1/3
✓ Branch 0 taken 5493498 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
5493498 switch(it)
2091 {
2092 case -2:
2093 {
2094 for(int32_t i=0; i<MAXLEVELS; i++)
2095 {
2096 if(game->lvlitems[i]&liCOMPASS)
2097 {
2098 return true;
2099 }
2100 }
2101
2102 return false;
2103 }
2104
2105 case -1:
2106 return (game->lvlitems[dlevel]&liCOMPASS)!=0;
2107
2108 default:
2109
2/4
✓ Branch 0 taken 5493498 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5493498 times.
✗ Branch 3 not taken.
5493498 if(it>=0&&it<MAXLEVELS)
2110 {
2111 5493498 return (game->lvlitems[it]&liCOMPASS)!=0;
2112 }
2113
2114 break;
2115 }
2116 return 0;
2117 }
2118
2119 case itype_bosskey: //it: -2=any, -1=current level, other=that level
2120 {
2121
1/3
✓ Branch 0 taken 115687 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
115687 switch(it)
2122 {
2123 case -2:
2124 {
2125 for(int32_t i=0; i<MAXLEVELS; i++)
2126 {
2127 if(game->lvlitems[i]&liBOSSKEY)
2128 {
2129 return true;
2130 }
2131 }
2132
2133 return false;
2134 }
2135
2136 case -1:
2137 return (game->lvlitems[dlevel]&liBOSSKEY)?1:0;
2138
2139 default:
2140
2/4
✓ Branch 0 taken 115687 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 115687 times.
115687 if(it>=0&&it<MAXLEVELS)
2141 {
2142 115687 return (game->lvlitems[it]&liBOSSKEY)?1:0;
2143 }
2144 break;
2145 }
2146 return 0;
2147 }
2148
2149 default:
2150 //it=(1<<(it-1));
2151 /*if (item_type>=itype_max)
2152 {
2153 enter_sys_pal();
2154 jwin_alert("Error","has_item exception",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2155 exit_sys_pal();
2156
2157 return false;
2158 }*/
2159 int32_t itemid = getItemID(itemsbuf, item_type, it);
2160
2161 if(itemid == -1)
2162 return false;
2163
2164 return game->get_item(itemid);
2165 }
2166 31050372 }
2167
2168
2169 99996708 int32_t current_item(int32_t item_type, bool checkenabled) //item currently being used
2170 {
2171
9/9
✓ Branch 0 taken 6052308 times.
✓ Branch 1 taken 51578244 times.
✓ Branch 2 taken 6052308 times.
✓ Branch 3 taken 6052308 times.
✓ Branch 4 taken 6052308 times.
✓ Branch 5 taken 6052308 times.
✓ Branch 6 taken 6052308 times.
✓ Branch 7 taken 6052308 times.
✓ Branch 8 taken 6052308 times.
99996708 switch(item_type)
2172 {
2173 case itype_clock:
2174 {
2175 6052308 int32_t maxid = getHighestLevelOfFamily(game, itemsbuf, item_type, checkenabled);
2176
2177
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6052308 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6052308 if(maxid != -1 && (itemsbuf[maxid].flags & ITEM_FLAG1)) //Active clock
2178 return itemsbuf[maxid].fam_type;
2179
2180 6052308 return has_item(itype_clock,1) ? 1 : 0;
2181 }
2182
2183 case itype_key:
2184 6052308 return game->get_keys();
2185
2186 case itype_lkey:
2187 6052308 return game->lvlkeys[get_dlevel()];
2188
2189 case itype_magiccontainer:
2190 6052308 return game->get_maxmagic()/game->get_mp_per_block();
2191
2192 case itype_triforcepiece:
2193 {
2194 6052308 int32_t count=0;
2195
2196
2/2
✓ Branch 0 taken 3098781696 times.
✓ Branch 1 taken 6052308 times.
3104834004 for(int32_t i=0; i<MAXLEVELS; i++)
2197 {
2198 3098781696 count+=(game->lvlitems[i]&liTRIFORCE)?1:0;
2199 3098781696 }
2200
2201 6052308 return count;
2202 }
2203
2204 case itype_map:
2205 {
2206 6052308 int32_t count=0;
2207
2208
2/2
✓ Branch 0 taken 3098781696 times.
✓ Branch 1 taken 6052308 times.
3104834004 for(int32_t i=0; i<MAXLEVELS; i++)
2209 {
2210 3098781696 count+=(game->lvlitems[i]&liMAP)?1:0;
2211 3098781696 }
2212
2213 6052308 return count;
2214 }
2215
2216 case itype_compass:
2217 {
2218 6052308 int32_t count=0;
2219
2220
2/2
✓ Branch 0 taken 3098781696 times.
✓ Branch 1 taken 6052308 times.
3104834004 for(int32_t i=0; i<MAXLEVELS; i++)
2221 {
2222 3098781696 count+=(game->lvlitems[i]&liCOMPASS)?1:0;
2223 3098781696 }
2224
2225 6052308 return count;
2226 }
2227
2228 case itype_bosskey:
2229 {
2230 6052308 int32_t count=0;
2231
2232
2/2
✓ Branch 0 taken 3098781696 times.
✓ Branch 1 taken 6052308 times.
3104834004 for(int32_t i=0; i<MAXLEVELS; i++)
2233 {
2234 3098781696 count+=(game->lvlitems[i]&liBOSSKEY)?1:0;
2235 3098781696 }
2236
2237 6052308 return count;
2238 }
2239
2240 default:
2241 51578244 int32_t maxid = getHighestLevelOfFamily(game, itemsbuf, item_type, checkenabled);
2242
2243
2/2
✓ Branch 0 taken 9870019 times.
✓ Branch 1 taken 41708225 times.
51578244 if(maxid == -1)
2244 41708225 return 0;
2245
2246 9870019 return itemsbuf[maxid].fam_type;
2247 }
2248 99996708 }
2249
2250 92380018 int32_t current_item(int32_t item_type) //item currently being used
2251 {
2252 92380018 return current_item(item_type, true);
2253 }
2254
2255 114 std::map<int32_t, int32_t> itemcache;
2256 114 std::map<int32_t, int32_t> itemcache_cost;
2257
2258 void removeFromItemCache(int32_t itemclass)
2259 {
2260 itemcache.erase(itemclass);
2261 itemcache_cost.erase(itemclass);
2262 }
2263
2264 5855816 void flushItemCache(bool justcost)
2265 {
2266 5855816 itemcache_cost.clear();
2267
2/2
✓ Branch 0 taken 5825900 times.
✓ Branch 1 taken 29916 times.
5855816 if(!justcost)
2268 29916 itemcache.clear();
2269
2/2
✓ Branch 0 taken 5825834 times.
✓ Branch 1 taken 66 times.
5825900 else if(replay_version_check(0,19))
2270 5825834 return;
2271
2272 //also fix the active subscreen if items were deleted -DD
2273
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29982 times.
29982 if(game != NULL)
2274 {
2275 29982 verifyBothWeapons();
2276 29982 refresh_subscr_items();
2277 29982 }
2278 5855816 }
2279
2280 // This is used often, so it should be as direct as possible.
2281 3375653419 int32_t _c_item_id_internal(int32_t itemtype, bool checkmagic, bool jinx_check)
2282 {
2283 3375653419 bool use_cost_cache = replay_version_check(19);
2284
2/2
✓ Branch 0 taken 3300096246 times.
✓ Branch 1 taken 75557173 times.
3375653419 if(jinx_check)
2285 {
2286
4/4
✓ Branch 0 taken 47348833 times.
✓ Branch 1 taken 28208340 times.
✓ Branch 2 taken 8273869 times.
✓ Branch 3 taken 39074964 times.
75557173 if(!(HeroSwordClk() || HeroItemClk()))
2287 39074964 jinx_check = false; //not jinxed
2288 75557173 }
2289
2/2
✓ Branch 0 taken 3346052808 times.
✓ Branch 1 taken 29600611 times.
3375653419 if(itemtype == itype_ring) checkmagic = true;
2290
6/6
✓ Branch 0 taken 3339171210 times.
✓ Branch 1 taken 36482209 times.
✓ Branch 2 taken 3337983293 times.
✓ Branch 3 taken 1187917 times.
✓ Branch 4 taken 3308725548 times.
✓ Branch 5 taken 29257745 times.
3375653419 if (!jinx_check && (use_cost_cache || itemtype != itype_ring))
2291 {
2292
4/4
✓ Branch 0 taken 185256959 times.
✓ Branch 1 taken 3124656506 times.
✓ Branch 2 taken 185141922 times.
✓ Branch 3 taken 115037 times.
3309913465 auto& cache = checkmagic && use_cost_cache ? itemcache_cost : itemcache;
2293 3309913465 auto res = cache.find(itemtype);
2294
2295
2/2
✓ Branch 0 taken 3294643466 times.
✓ Branch 1 taken 15269999 times.
3309913465 if(res != cache.end())
2296 3294643466 return res->second;
2297 15269999 }
2298
2299 81009953 int32_t result = -1;
2300 81009953 int32_t highestlevel = -1;
2301
2302
2/2
✓ Branch 0 taken 20738547968 times.
✓ Branch 1 taken 81009953 times.
20819557921 for(int32_t i=0; i<MAXITEMS; i++)
2303 {
2304
5/6
✓ Branch 0 taken 1520751486 times.
✓ Branch 1 taken 19217796482 times.
✓ Branch 2 taken 21880502 times.
✓ Branch 3 taken 1498870984 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 21880502 times.
20738547968 if(game->get_item(i) && itemsbuf[i].family==itemtype && !item_disabled(i))
2305 {
2306
4/4
✓ Branch 0 taken 20036814 times.
✓ Branch 1 taken 1843688 times.
✓ Branch 2 taken 8694 times.
✓ Branch 3 taken 20028120 times.
21880502 if(checkmagic && itemtype != itype_magicring)
2307
2/2
✓ Branch 0 taken 20027950 times.
✓ Branch 1 taken 170 times.
20028120 if(!checkmagiccost(i))
2308 170 continue;
2309
6/6
✓ Branch 0 taken 18586121 times.
✓ Branch 1 taken 3294211 times.
✓ Branch 2 taken 243036 times.
✓ Branch 3 taken 3051175 times.
✓ Branch 4 taken 1848085 times.
✓ Branch 5 taken 1446126 times.
21880332 if(jinx_check && (usesSwordJinx(i) ? HeroSwordClk() : HeroItemClk()))
2310
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1446126 times.
1446126 if(!(itemsbuf[i].flags & ITEM_JINX_IMMUNE))
2311 1446126 continue;
2312
2313
2/2
✓ Branch 0 taken 280080 times.
✓ Branch 1 taken 20154126 times.
20434206 if(itemsbuf[i].fam_type >= highestlevel)
2314 {
2315 20154126 highestlevel = itemsbuf[i].fam_type;
2316 20154126 result=i;
2317 20154126 }
2318 20434206 }
2319 20737101672 }
2320
2321
2/2
✓ Branch 0 taken 36482209 times.
✓ Branch 1 taken 44527744 times.
81009953 if(!jinx_check) //Can't cache jinx_check results
2322 {
2323
2/2
✓ Branch 0 taken 1676 times.
✓ Branch 1 taken 44526068 times.
44527744 if (use_cost_cache)
2324 {
2325
2/2
✓ Branch 0 taken 596 times.
✓ Branch 1 taken 1080 times.
1676 if (!checkmagic)
2326 1080 itemcache[itemtype] = result;
2327
5/6
✓ Branch 0 taken 1080 times.
✓ Branch 1 taken 596 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 1078 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
1676 if (checkmagic || result < 0 || checkmagiccost(result))
2328 1676 itemcache_cost[itemtype] = result;
2329 1676 }
2330 else
2331 {
2332 44526068 itemcache[itemtype] = result;
2333 }
2334 44527744 }
2335 81009953 return result;
2336 3375653419 }
2337
2338 // 'jinx_check' indicates that the highest level item *immune to jinxes* should be returned.
2339 3339615423 int32_t current_item_id(int32_t itype, bool checkmagic, bool jinx_check)
2340 {
2341
2/4
✓ Branch 0 taken 3339615423 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3339615423 times.
3339615423 if(itype < 0 || itype >= itype_max) return -1;
2342
1/2
✓ Branch 0 taken 3339615423 times.
✗ Branch 1 not taken.
3339615423 if(game->OverrideItems[itype] > -2)
2343 {
2344 auto ovid = game->OverrideItems[itype];
2345 if(ovid < 0 || ovid >= MAXITEMS)
2346 return -1;
2347 if(itemsbuf[ovid].family == itype)
2348 {
2349 if(itype == itype_magicring)
2350 checkmagic = false;
2351 else if(itype == itype_ring)
2352 checkmagic = true;
2353
2354 if(checkmagic && !checkmagiccost(ovid))
2355 return -1;
2356 if(jinx_check && !(itemsbuf[ovid].flags & ITEM_JINX_IMMUNE)
2357 && (usesSwordJinx(ovid) ? HeroSwordClk() : HeroItemClk()))
2358 return -1;
2359 return ovid;
2360 }
2361 }
2362 3339615423 auto ret = _c_item_id_internal(itype,checkmagic,jinx_check);
2363
2/2
✓ Branch 0 taken 39519177 times.
✓ Branch 1 taken 3300096246 times.
3339615423 if(!jinx_check) //If not already a jinx-immune-only check...
2364 {
2365 //And the player IS jinxed...
2366
4/4
✓ Branch 0 taken 3272230883 times.
✓ Branch 1 taken 27865363 times.
✓ Branch 2 taken 8172633 times.
✓ Branch 3 taken 3264058250 times.
3300096246 if(HeroSwordClk() || HeroItemClk())
2367 {
2368 //Then do a jinx-immune-only check here
2369 36037996 auto ret2 = _c_item_id_internal(itype,checkmagic,true);
2370 //And *IF IT FINDS A VALID ITEM*, return that one instead! -Em
2371 //Should NOT need a compat rule, as this should always return -1 in old quests.
2372
2/2
✓ Branch 0 taken 1263260 times.
✓ Branch 1 taken 34774736 times.
36037996 if(ret2 > -1) return ret2;
2373 34774736 }
2374 3298832986 }
2375 3338352163 return ret;
2376 3339615423 }
2377
2378 19330534 int32_t current_item_power(int32_t itemtype)
2379 {
2380 19330534 int32_t result = current_item_id(itemtype,true);
2381
2/2
✓ Branch 0 taken 14037928 times.
✓ Branch 1 taken 5292606 times.
19330534 return (result<0) ? 0 : itemsbuf[result].power;
2382 }
2383
2384 11 int32_t heart_container_id()
2385 {
2386
1/2
✓ Branch 0 taken 319 times.
✗ Branch 1 not taken.
319 for(int32_t i=0; i<MAXITEMS; i++)
2387 {
2388
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 308 times.
319 if(itemsbuf[i].family == itype_heartcontainer)
2389 {
2390 11 return i;
2391 }
2392 308 }
2393 return -1;
2394 11 }
2395
2396 6052308 int32_t item_tile_mod()
2397 {
2398 6052308 int32_t tile=0;
2399
2400
2/2
✓ Branch 0 taken 1206083 times.
✓ Branch 1 taken 4846225 times.
6052308 if(game->get_bombs())
2401 {
2402 4846225 int32_t itemid = current_item_id(itype_bomb,false);
2403
3/4
✓ Branch 0 taken 4681056 times.
✓ Branch 1 taken 165169 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4681056 times.
4846225 if(itemid > -1 && checkbunny(itemid))
2404 4681056 tile+=itemsbuf[itemid].ltm;
2405 4846225 }
2406
2407
2/2
✓ Branch 0 taken 4539018 times.
✓ Branch 1 taken 1513290 times.
6052308 if(game->get_sbombs())
2408 {
2409 1513290 int32_t itemid = current_item_id(itype_sbomb,false);
2410
3/4
✓ Branch 0 taken 1511862 times.
✓ Branch 1 taken 1428 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1511862 times.
1513290 if(itemid > -1 && checkbunny(itemid))
2411 1511862 tile+=itemsbuf[itemid].ltm;
2412 1513290 }
2413
2414
2/2
✓ Branch 0 taken 5942608 times.
✓ Branch 1 taken 109700 times.
6052308 if(current_item(itype_clock))
2415 {
2416 109700 int32_t itemid =
2417
1/2
✓ Branch 0 taken 109700 times.
✗ Branch 1 not taken.
109700 get_qr(qr_HARDCODED_LITEM_LTMS)
2418 ? iClock
2419 : getHighestLevelEvenUnowned(itemsbuf, itype_clock);
2420
2/4
✓ Branch 0 taken 109700 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 109700 times.
109700 if(itemid > -1 && checkbunny(itemid))
2421 109700 tile+=itemsbuf[itemid].ltm;
2422 109700 }
2423
2424
2/2
✓ Branch 0 taken 4671567 times.
✓ Branch 1 taken 1380741 times.
6052308 if(current_item(itype_key))
2425 {
2426 1380741 int32_t itemid =
2427
1/2
✓ Branch 0 taken 1380741 times.
✗ Branch 1 not taken.
1380741 get_qr(qr_HARDCODED_LITEM_LTMS)
2428 ? iKey
2429 : getHighestLevelEvenUnowned(itemsbuf, itype_key);
2430
2/4
✓ Branch 0 taken 1380741 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1380741 times.
1380741 if(itemid > -1 && checkbunny(itemid))
2431 1380741 tile+=itemsbuf[itemid].ltm;
2432 1380741 }
2433
2434
2/2
✓ Branch 0 taken 5785205 times.
✓ Branch 1 taken 267103 times.
6052308 if(current_item(itype_lkey))
2435 {
2436 267103 int32_t itemid =
2437
2/2
✓ Branch 0 taken 266193 times.
✓ Branch 1 taken 910 times.
267103 get_qr(qr_HARDCODED_LITEM_LTMS)
2438 ? iLevelKey
2439 910 : getHighestLevelEvenUnowned(itemsbuf, itype_lkey);
2440
2/4
✓ Branch 0 taken 267103 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 267103 times.
267103 if(itemid > -1 && checkbunny(itemid))
2441 267103 tile+=itemsbuf[itemid].ltm;
2442 267103 }
2443
2444
2/2
✓ Branch 0 taken 1256277 times.
✓ Branch 1 taken 4796031 times.
6052308 if(current_item(itype_map))
2445 {
2446 4796031 int32_t itemid =
2447
1/2
✓ Branch 0 taken 4796031 times.
✗ Branch 1 not taken.
4796031 get_qr(qr_HARDCODED_LITEM_LTMS)
2448 ? iMap
2449 : getHighestLevelEvenUnowned(itemsbuf, itype_map);
2450
2/4
✓ Branch 0 taken 4796031 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4796031 times.
4796031 if(itemid > -1 && checkbunny(itemid))
2451 4796031 tile+=itemsbuf[itemid].ltm;
2452 4796031 }
2453
2454
2/2
✓ Branch 0 taken 1233609 times.
✓ Branch 1 taken 4818699 times.
6052308 if(current_item(itype_compass))
2455 {
2456 4818699 int32_t itemid =
2457
2/2
✓ Branch 0 taken 4737640 times.
✓ Branch 1 taken 81059 times.
4818699 get_qr(qr_HARDCODED_LITEM_LTMS)
2458 ? iCompass
2459 81059 : getHighestLevelEvenUnowned(itemsbuf, itype_compass);
2460
2/4
✓ Branch 0 taken 4818699 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4818699 times.
4818699 if(itemid > -1 && checkbunny(itemid))
2461 4818699 tile+=itemsbuf[itemid].ltm;
2462 4818699 }
2463
2464
2/2
✓ Branch 0 taken 3421763 times.
✓ Branch 1 taken 2630545 times.
6052308 if(current_item(itype_bosskey))
2465 {
2466 2630545 int32_t itemid =
2467
1/2
✓ Branch 0 taken 2630545 times.
✗ Branch 1 not taken.
2630545 get_qr(qr_HARDCODED_LITEM_LTMS)
2468 ? iBossKey
2469 : getHighestLevelEvenUnowned(itemsbuf, itype_bosskey);
2470
2/4
✓ Branch 0 taken 2630545 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2630545 times.
2630545 if(itemid > -1 && checkbunny(itemid))
2471 2630545 tile+=itemsbuf[itemid].ltm;
2472 2630545 }
2473
2474
2/2
✓ Branch 0 taken 2919118 times.
✓ Branch 1 taken 3133190 times.
6052308 if(current_item(itype_magiccontainer))
2475 {
2476 3133190 int32_t itemid =
2477
2/2
✓ Branch 0 taken 3040989 times.
✓ Branch 1 taken 92201 times.
3133190 get_qr(qr_HARDCODED_LITEM_LTMS)
2478 ? iMagicC
2479 92201 : getHighestLevelEvenUnowned(itemsbuf, itype_magiccontainer);
2480
3/4
✓ Branch 0 taken 3133190 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1870 times.
✓ Branch 3 taken 3131320 times.
3133190 if(itemid > -1 && checkbunny(itemid))
2481 3131320 tile+=itemsbuf[itemid].ltm;
2482 3133190 }
2483
2484
2/2
✓ Branch 0 taken 1591674 times.
✓ Branch 1 taken 4460634 times.
6052308 if(current_item(itype_triforcepiece))
2485 {
2486 4460634 int32_t itemid =
2487
1/2
✓ Branch 0 taken 4460634 times.
✗ Branch 1 not taken.
4460634 get_qr(qr_HARDCODED_LITEM_LTMS)
2488 ? iTriforce
2489 : getHighestLevelEvenUnowned(itemsbuf, itype_triforcepiece);
2490
2/4
✓ Branch 0 taken 4460634 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4460634 times.
4460634 if(itemid > -1 && checkbunny(itemid))
2491 4460634 tile+=itemsbuf[itemid].ltm;
2492 4460634 }
2493
2494
2/2
✓ Branch 0 taken 6052308 times.
✓ Branch 1 taken 3098781696 times.
3104834004 for(int32_t i=0; i<itype_max; i++)
2495 {
2496
2/2
✓ Branch 0 taken 3042451456 times.
✓ Branch 1 taken 56330240 times.
3098781696 if(!get_qr(qr_HARDCODED_LITEM_LTMS))
2497 {
2498
2/2
✓ Branch 0 taken 1100200 times.
✓ Branch 1 taken 55230040 times.
56330240 switch(i)
2499 {
2500 case itype_bomb:
2501 case itype_sbomb:
2502 case itype_clock:
2503 case itype_key:
2504 case itype_lkey:
2505 case itype_map:
2506 case itype_compass:
2507 case itype_bosskey:
2508 case itype_magiccontainer:
2509 case itype_triforcepiece:
2510 1100200 continue; //already handled
2511 }
2512 55230040 }
2513 3097681496 int32_t itemid = current_item_id(i,false);
2514
2/2
✓ Branch 0 taken 3091629188 times.
✓ Branch 1 taken 6052308 times.
3097681496 if(i == itype_shield)
2515 6052308 itemid = getCurrentShield(false);
2516
2517
4/4
✓ Branch 0 taken 80828175 times.
✓ Branch 1 taken 3016853321 times.
✓ Branch 2 taken 100981 times.
✓ Branch 3 taken 80727194 times.
3097681496 if(itemid < 0 || !checkbunny(itemid))
2518 3016954302 continue;
2519
2520 80727194 itemdata const& itm = itemsbuf[itemid];
2521
2522
2/2
✓ Branch 0 taken 75312220 times.
✓ Branch 1 taken 5414974 times.
80727194 switch(itm.family)
2523 {
2524 case itype_shield:
2525
1/2
✓ Branch 0 taken 5414974 times.
✗ Branch 1 not taken.
5414974 if(itm.flags & ITEM_FLAG9) //active shield
2526 {
2527 if(!usingActiveShield(itemid))
2528 {
2529 tile+=itm.misc6; //'Inactive PTM'
2530 continue;
2531 }
2532 }
2533 5414974 break;
2534 }
2535
2536 80727194 tile+=itm.ltm;
2537 80727194 }
2538
2539 6052308 return tile;
2540 }
2541
2542 6052308 int32_t bunny_tile_mod()
2543 {
2544
2/2
✓ Branch 0 taken 1870 times.
✓ Branch 1 taken 6050438 times.
6052308 if(Hero.BunnyClock())
2545 {
2546 1870 return game->get_bunny_ltm();
2547 }
2548 6050438 return 0;
2549 6052308 }
2550
2551 // Hints are drawn on a separate layer to combo reveals.
2552 16332 void draw_lens_under(BITMAP *dest, bool layer)
2553 {
2554 //Lens flag 1: Replacement for qr_LENSHINTS; if set, lens will show hints. Does nothing if flag 2 is set.
2555 //Lens flag 2: Disable "hints", prevent rendering of Secret Combos
2556 //Lens flag 3: Don't show armos/chest/dive items
2557 //Lens flag 4: Show Raft Paths
2558 //Lens flag 5: Show Invisible Enemies
2559
4/4
✓ Branch 0 taken 456 times.
✓ Branch 1 taken 15876 times.
✓ Branch 2 taken 7938 times.
✓ Branch 3 taken 7938 times.
16332 bool hints = (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2) ? false : (layer && (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG1));
2560
2561 16332 int32_t strike_hint_table[11]=
2562 {
2563 mfARROW, mfBOMB, mfBRANG, mfWANDMAGIC,
2564 mfSWORD, mfREFMAGIC, mfHOOKSHOT,
2565 mfREFFIREBALL, mfHAMMER, mfSWORDBEAM, mfWAND
2566 };
2567
2568 // int32_t page = tmpscr->cpage;
2569 {
2570 16332 int32_t blink_rate=flash_reduction_enabled()?6:1;
2571 // int32_t temptimer=0;
2572 16332 int32_t tempitem, tempweapon=0;
2573 16332 strike_hint=strike_hint_table[strike_hint_counter];
2574
2575
2/2
✓ Branch 0 taken 15842 times.
✓ Branch 1 taken 490 times.
16332 if(strike_hint_timer>32)
2576 {
2577 490 strike_hint_timer=0;
2578 490 strike_hint_counter=((strike_hint_counter+1)%11);
2579 490 }
2580
2581 16332 ++strike_hint_timer;
2582
2583
2/2
✓ Branch 0 taken 2874432 times.
✓ Branch 1 taken 16332 times.
2890764 for(int32_t i=0; i<176; i++)
2584 {
2585 2874432 int32_t x = (i & 15) << 4;
2586 2874432 int32_t y = (i & 0xF0) + playing_field_offset;
2587 2874432 int32_t tempitemx=-16, tempitemy=-16;
2588 2874432 int32_t tempweaponx=-16, tempweapony=-16;
2589
2590
2/2
✓ Branch 0 taken 5748864 times.
✓ Branch 1 taken 2874432 times.
8623296 for(int32_t iter=0; iter<2; ++iter)
2591 {
2592 5748864 int32_t checkflag=0;
2593
2594
2/2
✓ Branch 0 taken 2874432 times.
✓ Branch 1 taken 2874432 times.
5748864 if(iter==0)
2595 {
2596 2874432 checkflag=combobuf[tmpscr->data[i]].flag;
2597 2874432 }
2598 else
2599 {
2600 2874432 checkflag=tmpscr->sflag[i];
2601 }
2602
2603
2/2
✓ Branch 0 taken 5747766 times.
✓ Branch 1 taken 1098 times.
5748864 if(checkflag==mfSTRIKE)
2604 {
2605
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 906 times.
1098 if(!hints)
2606 {
2607
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 906 times.
906 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTRIKE],tmpscr->secretcset[sSTRIKE]);
2608 906 }
2609 else
2610 {
2611 192 checkflag = strike_hint;
2612 }
2613 1098 }
2614
2615
20/36
✓ Branch 0 taken 5706470 times.
✓ Branch 1 taken 3148 times.
✓ Branch 2 taken 3618 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2064 times.
✓ Branch 5 taken 28640 times.
✓ Branch 6 taken 2418 times.
✓ Branch 7 taken 504 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 814 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 33 times.
✓ Branch 15 taken 96 times.
✓ Branch 16 taken 24 times.
✓ Branch 17 taken 5 times.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 16 times.
✓ Branch 22 taken 16 times.
✓ Branch 23 taken 7 times.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✓ Branch 27 taken 16 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✓ Branch 31 taken 17 times.
✓ Branch 32 taken 35 times.
✓ Branch 33 taken 17 times.
✗ Branch 34 not taken.
✓ Branch 35 taken 906 times.
5748864 switch(checkflag)
2616 {
2617 case 0:
2618 case mfZELDA:
2619 case mfPUSHED:
2620 case mfENEMY0:
2621 case mfENEMY1:
2622 case mfENEMY2:
2623 case mfENEMY3:
2624 case mfENEMY4:
2625 case mfENEMY5:
2626 case mfENEMY6:
2627 case mfENEMY7:
2628 case mfENEMY8:
2629 case mfENEMY9:
2630 case mfSINGLE:
2631 case mfSINGLE16:
2632 case mfNOENEMY:
2633 case mfTRAP_H:
2634 case mfTRAP_V:
2635 case mfTRAP_4:
2636 case mfTRAP_LR:
2637 case mfTRAP_UD:
2638 case mfNOGROUNDENEMY:
2639 case mfNOBLOCKS:
2640 case mfSCRIPT1:
2641 case mfSCRIPT2:
2642 case mfSCRIPT3:
2643 case mfSCRIPT4:
2644 case mfSCRIPT5:
2645 case mfSCRIPT6:
2646 case mfSCRIPT7:
2647 case mfSCRIPT8:
2648 case mfSCRIPT9:
2649 case mfSCRIPT10:
2650 case mfSCRIPT11:
2651 case mfSCRIPT12:
2652 case mfSCRIPT13:
2653 case mfSCRIPT14:
2654 case mfSCRIPT15:
2655 case mfSCRIPT16:
2656 case mfSCRIPT17:
2657 case mfSCRIPT18:
2658 case mfSCRIPT19:
2659 case mfSCRIPT20:
2660 case mfPITHOLE:
2661 case mfPITFALLFLOOR:
2662 case mfLAVA:
2663 case mfICE:
2664 case mfICEDAMAGE:
2665 case mfDAMAGE1:
2666 case mfDAMAGE2:
2667 case mfDAMAGE4:
2668 case mfDAMAGE8:
2669 case mfDAMAGE16:
2670 case mfDAMAGE32:
2671 case mfFREEZEALL:
2672 case mfFREZEALLANSFFCS:
2673 case mfFREEZEFFCSOLY:
2674 case mfSCRITPTW1TRIG:
2675 case mfSCRITPTW2TRIG:
2676 case mfSCRITPTW3TRIG:
2677 case mfSCRITPTW4TRIG:
2678 case mfSCRITPTW5TRIG:
2679 case mfSCRITPTW6TRIG:
2680 case mfSCRITPTW7TRIG:
2681 case mfSCRITPTW8TRIG:
2682 case mfSCRITPTW9TRIG:
2683 case mfSCRITPTW10TRIG:
2684 case mfTROWEL:
2685 case mfTROWELNEXT:
2686 case mfTROWELSPECIALITEM:
2687 case mfSLASHPOT:
2688 case mfLIFTPOT:
2689 case mfLIFTORSLASH:
2690 case mfLIFTROCK:
2691 case mfLIFTROCKHEAVY:
2692 case mfDROPITEM:
2693 case mfSPECIALITEM:
2694 case mfDROPKEY:
2695 case mfDROPLKEY:
2696 case mfDROPCOMPASS:
2697 case mfDROPMAP:
2698 case mfDROPBOSSKEY:
2699 case mfSPAWNNPC:
2700 case mfSWITCHHOOK:
2701 case mfSIDEVIEWLADDER:
2702 case mfSIDEVIEWPLATFORM:
2703 case mfNOENEMYSPAWN:
2704 case mfENEMYALL:
2705 case mfNOMIRROR:
2706 case mfUNSAFEGROUND:
2707 case mf168:
2708 case mf169:
2709 case mf170:
2710 case mf171:
2711 case mf172:
2712 case mf173:
2713 case mf174:
2714 case mf175:
2715 case mf176:
2716 case mf177:
2717 case mf178:
2718 case mf179:
2719 case mf180:
2720 case mf181:
2721 case mf182:
2722 case mf183:
2723 case mf184:
2724 case mf185:
2725 case mf186:
2726 case mf187:
2727 case mf188:
2728 case mf189:
2729 case mf190:
2730 case mf191:
2731 case mf192:
2732 case mf193:
2733 case mf194:
2734 case mf195:
2735 case mf196:
2736 case mf197:
2737 case mf198:
2738 case mf199:
2739 case mf200:
2740 case mf201:
2741 case mf202:
2742 case mf203:
2743 case mf204:
2744 case mf205:
2745 case mf206:
2746 case mf207:
2747 case mf208:
2748 case mf209:
2749 case mf210:
2750 case mf211:
2751 case mf212:
2752 case mf213:
2753 case mf214:
2754 case mf215:
2755 case mf216:
2756 case mf217:
2757 case mf218:
2758 case mf219:
2759 case mf220:
2760 case mf221:
2761 case mf222:
2762 case mf223:
2763 case mf224:
2764 case mf225:
2765 case mf226:
2766 case mf227:
2767 case mf228:
2768 case mf229:
2769 case mf230:
2770 case mf231:
2771 case mf232:
2772 case mf233:
2773 case mf234:
2774 case mf235:
2775 case mf236:
2776 case mf237:
2777 case mf238:
2778 case mf239:
2779 case mf240:
2780 case mf241:
2781 case mf242:
2782 case mf243:
2783 case mf244:
2784 case mf245:
2785 case mf246:
2786 case mf247:
2787 case mf248:
2788 case mf249:
2789 case mf250:
2790 case mf251:
2791 case mf252:
2792 case mf253:
2793 case mf254:
2794 case mfEXTENDED:
2795 5706470 break;
2796
2797 case mfPUSHUD:
2798 case mfPUSHLR:
2799 case mfPUSH4:
2800 case mfPUSHU:
2801 case mfPUSHD:
2802 case mfPUSHL:
2803 case mfPUSHR:
2804 case mfPUSHUDNS:
2805 case mfPUSHLRNS:
2806 case mfPUSH4NS:
2807 case mfPUSHUNS:
2808 case mfPUSHDNS:
2809 case mfPUSHLNS:
2810 case mfPUSHRNS:
2811 case mfPUSHUDINS:
2812 case mfPUSHLRINS:
2813 case mfPUSH4INS:
2814 case mfPUSHUINS:
2815 case mfPUSHDINS:
2816 case mfPUSHLINS:
2817 case mfPUSHRINS:
2818
3/4
✓ Branch 0 taken 1829 times.
✓ Branch 1 taken 1319 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1829 times.
3148 if(!hints && ((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&16))
2819
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1829 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1829 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1829 || ((get_debug() && zc_getkey(KEY_N)) && (frame&16))))
2820 {
2821 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->undercombo,tmpscr->undercset);
2822 }
2823
2824
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3148 times.
3148 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2825
3/6
✓ Branch 0 taken 2438 times.
✓ Branch 1 taken 710 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 710 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3148 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2826 {
2827
2/2
✓ Branch 0 taken 1406 times.
✓ Branch 1 taken 1032 times.
2438 if(hints)
2828 {
2829
3/3
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 63 times.
✓ Branch 2 taken 897 times.
1032 switch(combobuf[tmpscr->data[i]].type)
2830 {
2831 case cPUSH_HEAVY:
2832 case cPUSH_HW:
2833 72 tempitem=getItemIDPower(itemsbuf,itype_bracelet,1);
2834 72 tempitemx=x, tempitemy=y;
2835
2836
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
72 if(tempitem>-1)
2837 72 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2838
2839 72 break;
2840
2841 case cPUSH_HEAVY2:
2842 case cPUSH_HW2:
2843 63 tempitem=getItemIDPower(itemsbuf,itype_bracelet,2);
2844 63 tempitemx=x, tempitemy=y;
2845
2846
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(tempitem>-1)
2847 63 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2848
2849 63 break;
2850 }
2851 1032 }
2852 2438 }
2853
2854 3148 break;
2855
2856 case mfWHISTLE:
2857
1/2
✓ Branch 0 taken 2418 times.
✗ Branch 1 not taken.
2418 if(hints)
2858 {
2859 tempitem=getItemID(itemsbuf,itype_whistle,1);
2860
2861 if(tempitem<0) break;
2862
2863 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2864 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2865 {
2866 tempitemx=x;
2867 tempitemy=y;
2868 }
2869
2870 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2871 }
2872
2873 2418 break;
2874
2875 //Why is this here?
2876 case mfFAIRY:
2877 case mfMAGICFAIRY:
2878 case mfALLFAIRY:
2879 if(hints)
2880 {
2881 tempitem=getItemID(itemsbuf, itype_fairy,1);//iFairyMoving;
2882
2883 if(tempitem < 0) break;
2884
2885 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2886 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2887 {
2888 tempitemx=x;
2889 tempitemy=y;
2890 }
2891
2892 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2893 }
2894
2895 break;
2896
2897 case mfANYFIRE:
2898
2/2
✓ Branch 0 taken 252 times.
✓ Branch 1 taken 252 times.
504 if(!hints)
2899 {
2900
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252 times.
252 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBCANDLE],tmpscr->secretcset[sBCANDLE]);
2901 252 }
2902 else
2903 {
2904 252 tempitem=getItemID(itemsbuf,itype_candle,1);
2905
2906
1/2
✓ Branch 0 taken 252 times.
✗ Branch 1 not taken.
252 if(tempitem<0) break;
2907
2908
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252 times.
252 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2909
3/6
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 63 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 63 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
252 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2910 {
2911 189 tempitemx=x;
2912 189 tempitemy=y;
2913 189 }
2914
2915 252 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2916 }
2917
2918 504 break;
2919
2920 case mfSTRONGFIRE:
2921 if(!hints)
2922 {
2923 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sRCANDLE],tmpscr->secretcset[sRCANDLE]);
2924 }
2925 else
2926 {
2927 tempitem=getItemID(itemsbuf,itype_candle,2);
2928
2929 if(tempitem<0) break;
2930
2931 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2932 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2933 {
2934 tempitemx=x;
2935 tempitemy=y;
2936 }
2937
2938 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2939 }
2940
2941 break;
2942
2943 case mfMAGICFIRE:
2944 if(!hints)
2945 {
2946 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDFIRE],tmpscr->secretcset[sWANDFIRE]);
2947 }
2948 else
2949 {
2950 tempitem=getItemID(itemsbuf,itype_wand,1);
2951
2952 if(tempitem<0) break;
2953
2954 tempweapon=wFire;
2955
2956 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2957 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2958 {
2959 tempitemx=x;
2960 tempitemy=y;
2961 }
2962 else
2963 {
2964 tempweaponx=x;
2965 tempweapony=y;
2966 }
2967
2968 putweapon(dest,tempweaponx,tempweapony,tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
2969 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2970 }
2971
2972 break;
2973
2974 case mfDIVINEFIRE:
2975 if(!hints)
2976 {
2977 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sDIVINEFIRE],tmpscr->secretcset[sDIVINEFIRE]);
2978 }
2979 else
2980 {
2981 tempitem=getItemID(itemsbuf,itype_divinefire,1);
2982
2983 if(tempitem<0) break;
2984
2985 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2986 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2987 {
2988 tempitemx=x;
2989 tempitemy=y;
2990 }
2991
2992 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2993 }
2994
2995 break;
2996
2997 case mfARROW:
2998
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 732 times.
814 if(!hints)
2999 {
3000
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 732 times.
732 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sARROW],tmpscr->secretcset[sARROW]);
3001 732 }
3002 else
3003 {
3004 82 tempitem=getItemID(itemsbuf,itype_arrow,1);
3005
3006
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if(tempitem<0) break;
3007
3008
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3009
3/6
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 21 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
82 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3010 {
3011 61 tempitemx=x;
3012 61 tempitemy=y;
3013 61 }
3014
3015 82 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3016 }
3017
3018 814 break;
3019
3020 case mfSARROW:
3021 if(!hints)
3022 {
3023 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSARROW],tmpscr->secretcset[sSARROW]);
3024 }
3025 else
3026 {
3027 tempitem=getItemID(itemsbuf,itype_arrow,2);
3028
3029 if(tempitem<0) break;
3030
3031 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3032 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3033 {
3034 tempitemx=x;
3035 tempitemy=y;
3036 }
3037
3038 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3039 }
3040
3041 break;
3042
3043 case mfGARROW:
3044 if(!hints)
3045 {
3046 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sGARROW],tmpscr->secretcset[sGARROW]);
3047 }
3048 else
3049 {
3050 tempitem=getItemID(itemsbuf,itype_arrow,3);
3051
3052 if(tempitem<0) break;
3053
3054 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3055 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3056 {
3057 tempitemx=x;
3058 tempitemy=y;
3059 }
3060
3061 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3062 }
3063
3064 break;
3065
3066 case mfBOMB:
3067
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 16 times.
33 if(!hints)
3068 {
3069
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBOMB],tmpscr->secretcset[sBOMB]);
3070 16 }
3071 else
3072 {
3073 //tempitem=getItemID(itemsbuf,itype_bomb,1);
3074 17 tempweapon = wLitBomb;
3075
3076 //if (tempitem<0) break;
3077
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3078
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3079 {
3080 12 tempweaponx=x;
3081 12 tempweapony=y;
3082 12 }
3083
3084 17 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3085 }
3086
3087 33 break;
3088
3089 case mfSBOMB:
3090
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 48 times.
96 if(!hints)
3091 {
3092
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSBOMB],tmpscr->secretcset[sSBOMB]);
3093 48 }
3094 else
3095 {
3096 //tempitem=getItemID(itemsbuf,itype_sbomb,1);
3097 //if (tempitem<0) break;
3098 48 tempweapon = wLitSBomb;
3099
3100
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3101
3/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
48 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3102 {
3103 36 tempweaponx=x;
3104 36 tempweapony=y;
3105 36 }
3106
3107 48 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3108 }
3109
3110 96 break;
3111
3112 case mfARMOS_SECRET:
3113
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 12 times.
24 if(!hints)
3114 {
3115
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
3116 12 }
3117 24 break;
3118
3119 case mfBRANG:
3120
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(!hints)
3121 {
3122 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBRANG],tmpscr->secretcset[sBRANG]);
3123 }
3124 else
3125 {
3126 5 tempitem=getItemID(itemsbuf,itype_brang,1);
3127
3128
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(tempitem<0) break;
3129
3130
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3131
3/6
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
5 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3132 {
3133 4 tempitemx=x;
3134 4 tempitemy=y;
3135 4 }
3136
3137 5 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3138 }
3139
3140 5 break;
3141
3142 case mfMBRANG:
3143 if(!hints)
3144 {
3145 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMBRANG],tmpscr->secretcset[sMBRANG]);
3146 }
3147 else
3148 {
3149 tempitem=getItemID(itemsbuf,itype_brang,2);
3150
3151 if(tempitem<0) break;
3152
3153 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3154 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3155 {
3156 tempitemx=x;
3157 tempitemy=y;
3158 }
3159
3160 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3161 }
3162
3163 break;
3164
3165 case mfFBRANG:
3166 if(!hints)
3167 {
3168 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sFBRANG],tmpscr->secretcset[sFBRANG]);
3169 }
3170 else
3171 {
3172 tempitem=getItemID(itemsbuf,itype_brang,3);
3173
3174 if(tempitem<0) break;
3175
3176 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3177 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3178 {
3179 tempitemx=x;
3180 tempitemy=y;
3181 }
3182
3183 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3184 }
3185
3186 break;
3187
3188 case mfWANDMAGIC:
3189 if(!hints)
3190 {
3191 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDMAGIC],tmpscr->secretcset[sWANDMAGIC]);
3192 }
3193 else
3194 {
3195 tempitem=getItemID(itemsbuf,itype_wand,1);
3196
3197 if(tempitem<0) break;
3198
3199 tempweapon=itemsbuf[tempitem].wpn3;
3200
3201 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3202 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3203 {
3204 tempitemx=x;
3205 tempitemy=y;
3206 }
3207 else
3208 {
3209 tempweaponx=x;
3210 tempweapony=y;
3211 --lens_hint_weapon[wMagic][4];
3212
3213 if(lens_hint_weapon[wMagic][4]<-8)
3214 {
3215 lens_hint_weapon[wMagic][4]=8;
3216 }
3217 }
3218
3219 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3220 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3221 }
3222
3223 break;
3224
3225 case mfREFMAGIC:
3226
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3227 {
3228 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFMAGIC],tmpscr->secretcset[sREFMAGIC]);
3229 }
3230 else
3231 {
3232 16 tempitem=getItemID(itemsbuf,itype_shield,3);
3233
3234
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3235
3236 16 tempweapon=ewMagic;
3237
3238
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3239
3/6
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3240 {
3241 13 tempitemx=x;
3242 13 tempitemy=y;
3243 13 }
3244 else
3245 {
3246 3 tempweaponx=x;
3247 3 tempweapony=y;
3248
3249
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
3 if(lens_hint_weapon[ewMagic][2]==up)
3250 {
3251 1 --lens_hint_weapon[ewMagic][4];
3252 1 }
3253 else
3254 {
3255 2 ++lens_hint_weapon[ewMagic][4];
3256 }
3257
3258
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(lens_hint_weapon[ewMagic][4]>8)
3259 {
3260 lens_hint_weapon[ewMagic][2]=up;
3261 }
3262
3263
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
3 if(lens_hint_weapon[ewMagic][4]<=0)
3264 {
3265 2 lens_hint_weapon[ewMagic][2]=down;
3266 2 }
3267 }
3268
3269 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3270 16 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, lens_hint_weapon[ewMagic][2], lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3271 }
3272
3273 16 break;
3274
3275 case mfREFFIREBALL:
3276
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3277 {
3278 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFFIREBALL],tmpscr->secretcset[sREFFIREBALL]);
3279 }
3280 else
3281 {
3282 16 tempitem=getItemID(itemsbuf,itype_shield,3);
3283
3284
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3285
3286 16 tempweapon=ewFireball;
3287
3288
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3289
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3290 {
3291 12 tempitemx=x;
3292 12 tempitemy=y;
3293 12 tempweaponx=x;
3294 12 tempweapony=y;
3295 12 ++lens_hint_weapon[ewFireball][3];
3296
3297
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 1 times.
12 if(lens_hint_weapon[ewFireball][3]>8)
3298 {
3299 1 lens_hint_weapon[ewFireball][3]=-8;
3300 1 lens_hint_weapon[ewFireball][4]=8;
3301 1 }
3302
3303
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 4 times.
12 if(lens_hint_weapon[ewFireball][3]>0)
3304 {
3305 8 ++lens_hint_weapon[ewFireball][4];
3306 8 }
3307 else
3308 {
3309 4 --lens_hint_weapon[ewFireball][4];
3310 }
3311 12 }
3312
3313 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3314 16 putweapon(dest,tempweaponx+lens_hint_weapon[tempweapon][3],tempweapony+lens_hint_weapon[ewFireball][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3315 }
3316
3317 16 break;
3318
3319 case mfSWORD:
3320
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(!hints)
3321 {
3322 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORD],tmpscr->secretcset[sSWORD]);
3323 }
3324 else
3325 {
3326 7 tempitem=getItemID(itemsbuf,itype_sword,1);
3327
3328
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(tempitem<0) break;
3329
3330
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3331
3/6
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3332 {
3333 5 tempitemx=x;
3334 5 tempitemy=y;
3335 5 }
3336
3337 7 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3338 }
3339
3340 7 break;
3341
3342 case mfWSWORD:
3343 if(!hints)
3344 {
3345 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORD],tmpscr->secretcset[sWSWORD]);
3346 }
3347 else
3348 {
3349 tempitem=getItemID(itemsbuf,itype_sword,2);
3350
3351 if(tempitem<0) break;
3352
3353 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3354 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3355 {
3356 tempitemx=x;
3357 tempitemy=y;
3358 }
3359
3360 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3361 }
3362
3363 break;
3364
3365 case mfMSWORD:
3366 if(!hints)
3367 {
3368 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORD],tmpscr->secretcset[sMSWORD]);
3369 }
3370 else
3371 {
3372 tempitem=getItemID(itemsbuf,itype_sword,3);
3373
3374 if(tempitem<0) break;
3375
3376 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3377 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3378 {
3379 tempitemx=x;
3380 tempitemy=y;
3381 }
3382
3383 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3384 }
3385
3386 break;
3387
3388 case mfXSWORD:
3389 if(!hints)
3390 {
3391 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORD],tmpscr->secretcset[sXSWORD]);
3392 }
3393 else
3394 {
3395 tempitem=getItemID(itemsbuf,itype_sword,4);
3396
3397 if(tempitem<0) break;
3398
3399 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3400 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3401 {
3402 tempitemx=x;
3403 tempitemy=y;
3404 }
3405
3406 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3407 }
3408
3409 break;
3410
3411 case mfSWORDBEAM:
3412
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3413 {
3414 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORDBEAM],tmpscr->secretcset[sSWORDBEAM]);
3415 }
3416 else
3417 {
3418 16 tempitem=getItemID(itemsbuf,itype_sword,1);
3419
3420
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3421
3422
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3423
3/6
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3424 {
3425 11 tempitemx=x;
3426 11 tempitemy=y;
3427 11 }
3428
3429 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 1);
3430 }
3431
3432 16 break;
3433
3434 case mfWSWORDBEAM:
3435 if(!hints)
3436 {
3437 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORDBEAM],tmpscr->secretcset[sWSWORDBEAM]);
3438 }
3439 else
3440 {
3441 tempitem=getItemID(itemsbuf,itype_sword,2);
3442
3443 if(tempitem<0) break;
3444
3445 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3446 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3447 {
3448 tempitemx=x;
3449 tempitemy=y;
3450 }
3451
3452 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 2);
3453 }
3454
3455 break;
3456
3457 case mfMSWORDBEAM:
3458 if(!hints)
3459 {
3460 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORDBEAM],tmpscr->secretcset[sMSWORDBEAM]);
3461 }
3462 else
3463 {
3464 tempitem=getItemID(itemsbuf,itype_sword,3);
3465
3466 if(tempitem<0) break;
3467
3468 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3469 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3470 {
3471 tempitemx=x;
3472 tempitemy=y;
3473 }
3474
3475 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 3);
3476 }
3477
3478 break;
3479
3480 case mfXSWORDBEAM:
3481 if(!hints)
3482 {
3483 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORDBEAM],tmpscr->secretcset[sXSWORDBEAM]);
3484 }
3485 else
3486 {
3487 tempitem=getItemID(itemsbuf,itype_sword,4);
3488
3489 if(tempitem<0) break;
3490
3491 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3492 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3493 {
3494 tempitemx=x;
3495 tempitemy=y;
3496 }
3497
3498 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 4);
3499 }
3500
3501 break;
3502
3503 case mfHOOKSHOT:
3504
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!hints)
3505 {
3506 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHOOKSHOT],tmpscr->secretcset[sHOOKSHOT]);
3507 }
3508 else
3509 {
3510 17 tempitem=getItemID(itemsbuf,itype_hookshot,1);
3511
3512
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(tempitem<0) break;
3513
3514
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3515
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3516 {
3517 12 tempitemx=x;
3518 12 tempitemy=y;
3519 12 }
3520
3521 17 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3522 }
3523
3524 17 break;
3525
3526 case mfWAND:
3527
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!hints)
3528 {
3529 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWAND],tmpscr->secretcset[sWAND]);
3530 }
3531 else
3532 {
3533 35 tempitem=getItemID(itemsbuf,itype_wand,1);
3534
3535
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(tempitem<0) break;
3536
3537
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3538
3/6
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
35 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3539 {
3540 28 tempitemx=x;
3541 28 tempitemy=y;
3542 28 }
3543
3544 35 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3545 }
3546
3547 35 break;
3548
3549 case mfHAMMER:
3550
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!hints)
3551 {
3552 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHAMMER],tmpscr->secretcset[sHAMMER]);
3553 }
3554 else
3555 {
3556 17 tempitem=getItemID(itemsbuf,itype_hammer,1);
3557
3558
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(tempitem<0) break;
3559
3560
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3561
3/6
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3562 {
3563 13 tempitemx=x;
3564 13 tempitemy=y;
3565 13 }
3566
3567 17 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3568 }
3569
3570 17 break;
3571
3572 case mfARMOS_ITEM:
3573 case mfDIVE_ITEM:
3574
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2064 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2064 times.
2064 if((!getmapflag() || (tmpscr->flags9&fBELOWRETURN)) && !(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG3))
3575 {
3576 2064 putitem2(dest,x,y,tmpscr->catchall, lens_hint_item[tmpscr->catchall][0], lens_hint_item[tmpscr->catchall][1], 0);
3577 2064 }
3578 2064 break;
3579
3580 case 16:
3581 case 17:
3582 case 18:
3583 case 19:
3584 case 20:
3585 case 21:
3586 case 22:
3587 case 23:
3588 case 24:
3589 case 25:
3590 case 26:
3591 case 27:
3592 case 28:
3593 case 29:
3594 case 30:
3595 case 31:
3596
2/2
✓ Branch 0 taken 1008 times.
✓ Branch 1 taken 2610 times.
3618 if(!hints)
3597
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2610 times.
5220 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3598 2610 putcombo(dest,x,y,tmpscr->secretcombo[checkflag-16+4],tmpscr->secretcset[checkflag-16+4]);
3599
3600 3618 break;
3601 case mfSECRETSNEXT:
3602 if(!hints)
3603 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3604 putcombo(dest,x,y,tmpscr->data[i]+1,tmpscr->cset[i]);
3605
3606 break;
3607
3608 case mfSTRIKE:
3609
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 906 times.
906 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3610 {
3611 906 goto special;
3612 }
3613 else
3614 {
3615 break;
3616 }
3617
3618 28640 default: goto special;
3619
3620 special:
3621
8/8
✓ Branch 0 taken 14677 times.
✓ Branch 1 taken 14869 times.
✓ Branch 2 taken 473 times.
✓ Branch 3 taken 14204 times.
✓ Branch 4 taken 441 times.
✓ Branch 5 taken 32 times.
✓ Branch 6 taken 6108 times.
✓ Branch 7 taken 8128 times.
29546 if(layer && ((checkflag!=mfRAFT && checkflag!=mfRAFT_BRANCH&& checkflag!=mfRAFT_BOUNCE) ||(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG4)))
3622 {
3623
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 6549 times.
✓ Branch 2 taken 4913 times.
✓ Branch 3 taken 1636 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1636 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
6549 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate)) || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3624 {
3625 4913 rectfill(dest,x,y,x+15,y+15,WHITE);
3626 4913 }
3627 6549 }
3628
3629 29546 break;
3630 }
3631 5748864 }
3632 2874432 }
3633
3634
2/2
✓ Branch 0 taken 8166 times.
✓ Branch 1 taken 8166 times.
16332 if(layer)
3635 {
3636
2/2
✓ Branch 0 taken 7978 times.
✓ Branch 1 taken 188 times.
8166 if(tmpscr->door[0]==dWALK)
3637 188 rectfill(dest, 120, 16+playing_field_offset, 135, 31+playing_field_offset, WHITE);
3638
3639
2/2
✓ Branch 0 taken 7969 times.
✓ Branch 1 taken 197 times.
8166 if(tmpscr->door[1]==dWALK)
3640 197 rectfill(dest, 120, 144+playing_field_offset, 135, 159+playing_field_offset, WHITE);
3641
3642
2/2
✓ Branch 0 taken 8014 times.
✓ Branch 1 taken 152 times.
8166 if(tmpscr->door[2]==dWALK)
3643 152 rectfill(dest, 16, 80+playing_field_offset, 31, 95+playing_field_offset, WHITE);
3644
3645
2/2
✓ Branch 0 taken 7940 times.
✓ Branch 1 taken 226 times.
8166 if(tmpscr->door[3]==dWALK)
3646 226 rectfill(dest, 224, 80+playing_field_offset, 239, 95+playing_field_offset, WHITE);
3647
3648
2/2
✓ Branch 0 taken 8123 times.
✓ Branch 1 taken 43 times.
8166 if(tmpscr->door[0]==dBOMB)
3649 {
3650 43 showbombeddoor(dest, 0);
3651 43 }
3652
3653
2/2
✓ Branch 0 taken 8127 times.
✓ Branch 1 taken 39 times.
8166 if(tmpscr->door[1]==dBOMB)
3654 {
3655 39 showbombeddoor(dest, 1);
3656 39 }
3657
3658
1/2
✓ Branch 0 taken 8166 times.
✗ Branch 1 not taken.
8166 if(tmpscr->door[2]==dBOMB)
3659 {
3660 showbombeddoor(dest, 2);
3661 }
3662
3663
2/2
✓ Branch 0 taken 8129 times.
✓ Branch 1 taken 37 times.
8166 if(tmpscr->door[3]==dBOMB)
3664 {
3665 37 showbombeddoor(dest, 3);
3666 37 }
3667 8166 }
3668
3669
2/2
✓ Branch 0 taken 14298 times.
✓ Branch 1 taken 2034 times.
16332 if(tmpscr->stairx + tmpscr->stairy)
3670 {
3671
2/2
✓ Branch 0 taken 911 times.
✓ Branch 1 taken 1123 times.
2034 if(!hints)
3672 {
3673
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1123 times.
1123 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3674 1123 putcombo(dest,tmpscr->stairx,tmpscr->stairy+playing_field_offset,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
3675 1123 }
3676 else
3677 {
3678
2/2
✓ Branch 0 taken 863 times.
✓ Branch 1 taken 48 times.
911 if(tmpscr->flags&fWHISTLE)
3679 {
3680 48 tempitem=getItemID(itemsbuf,itype_whistle,1);
3681 48 int32_t tempitemx=-16;
3682 48 int32_t tempitemy=-16;
3683
3684
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&(blink_rate/4)))
3685
3/6
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
48 || ((get_debug() && zc_getkey(KEY_N)) && (frame&(blink_rate/4))))
3686 {
3687 24 tempitemx=tmpscr->stairx;
3688 24 tempitemy=tmpscr->stairy+playing_field_offset;
3689 24 }
3690
3691 48 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3692 48 }
3693 }
3694 2034 }
3695 }
3696 16332 }
3697
3698 BITMAP *lens_scr_d; // The "d" is for "destructible"!
3699
3700 7997 void draw_lens_over()
3701 {
3702 // Oh, what the heck.
3703 static BITMAP *lens_scr = NULL;
3704 static int32_t last_width = -1;
3705 7997 int32_t width = itemsbuf[current_item_id(itype_lens,true)].misc1;
3706
3707 // Only redraw the circle if the size has changed
3708
2/2
✓ Branch 0 taken 7987 times.
✓ Branch 1 taken 10 times.
7997 if(width != last_width)
3709 {
3710
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 if(lens_scr == NULL)
3711 {
3712 10 lens_scr = create_bitmap_ex(8,2*288,2*(240-playing_field_offset));
3713 10 }
3714
3715 10 clear_to_color(lens_scr, BLACK);
3716 10 circlefill(lens_scr, 288, 240-playing_field_offset, width, 0);
3717 10 circle(lens_scr, 288, 240-playing_field_offset, width+2, 0);
3718 10 circle(lens_scr, 288, 240-playing_field_offset, width+5, 0);
3719 10 last_width=width;
3720 10 }
3721
3722 7997 masked_blit(lens_scr, framebuf, 288-(HeroX()+8), 240-playing_field_offset-(HeroY()+8), 0, playing_field_offset, 256, 168);
3723 7997 do_primitives(framebuf, SPLAYER_LENS_OVER, tmpscr, 0, playing_field_offset);
3724 7997 }
3725
3726 //----------------------------------------------------------------
3727
3728 31111 void draw_wavy(BITMAP *source, BITMAP *target, int32_t amplitude, bool interpol)
3729 {
3730 //recreating a big bitmap every frame is highly sluggish.
3731
4/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 31108 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
31111 static BITMAP *wavebuf = create_bitmap_ex(8,288,240-original_playing_field_offset);
3732 31111 clear_to_color(wavebuf, BLACK);
3733 31111 blit(source,wavebuf,0,original_playing_field_offset,16,0,256,224-original_playing_field_offset);
3734
3735 int32_t ofs;
3736 // int32_t amplitude=8;
3737 // int32_t wavelength=4;
3738
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31111 times.
31111 amplitude = zc_min(2048,amplitude); // some arbitrary limit to prevent crashing
3739
3/6
✓ Branch 0 taken 31111 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 31111 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 31111 times.
31111 if(flash_reduction_enabled() && !get_qr(qr_WAVY_NO_EPILEPSY)) amplitude = zc_min(16,amplitude);
3740 31111 int32_t amp2=168;
3741
2/4
✓ Branch 0 taken 31111 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 31111 times.
31111 if(flash_reduction_enabled() && !get_qr(qr_WAVY_NO_EPILEPSY_2)) amp2*=2;
3742 31111 int32_t i=frame%amp2;
3743
3744
2/2
✓ Branch 0 taken 5226648 times.
✓ Branch 1 taken 31111 times.
5257759 for(int32_t j=0; j<168; j++)
3745 {
3746
3/4
✓ Branch 0 taken 2613324 times.
✓ Branch 1 taken 2613324 times.
✓ Branch 2 taken 2613324 times.
✗ Branch 3 not taken.
5226648 if(j&1 && interpol)
3747 {
3748 // Add 288*2048 to ensure it's never negative. It'll get modded out.
3749 ofs=288*2048+int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3750 }
3751 else
3752 {
3753 5226648 ofs=288*2048-int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3754 }
3755
3756
1/2
✓ Branch 0 taken 5226648 times.
✗ Branch 1 not taken.
5226648 if(ofs)
3757 {
3758
2/2
✓ Branch 0 taken 1338021888 times.
✓ Branch 1 taken 5226648 times.
1343248536 for(int32_t k=0; k<256; k++)
3759 {
3760 1338021888 target->line[j+original_playing_field_offset][k]=wavebuf->line[j][(k+ofs+16)%288];
3761 1338021888 }
3762 5226648 }
3763 5226648 }
3764 31111 }
3765
3766 4848 void draw_fuzzy(int32_t fuzz)
3767 // draws from right half of scrollbuf to framebuf
3768 {
3769 int32_t firstx, firsty, xstep, ystep, i, y, dx, dy;
3770 byte *start, *si, *di;
3771
3772
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4848 times.
4848 if(fuzz<1)
3773 fuzz = 1;
3774
3775 4848 xstep = 128%fuzz;
3776
3777
2/2
✓ Branch 0 taken 1010 times.
✓ Branch 1 taken 3838 times.
4848 if(xstep > 0)
3778 3838 xstep = fuzz-xstep;
3779
3780 4848 ystep = 112%fuzz;
3781
3782
2/2
✓ Branch 0 taken 1414 times.
✓ Branch 1 taken 3434 times.
4848 if(ystep > 0)
3783 3434 ystep = fuzz-ystep;
3784
3785 4848 firsty = 1;
3786
3787
2/2
✓ Branch 0 taken 4848 times.
✓ Branch 1 taken 174932 times.
179780 for(y=0; y<224;)
3788 {
3789 174932 start = &(scrollbuf->line[y][256]);
3790
3791
4/4
✓ Branch 0 taken 172508 times.
✓ Branch 1 taken 1088376 times.
✓ Branch 2 taken 1085952 times.
✓ Branch 3 taken 174932 times.
1260884 for(dy=0; dy<ystep && dy+y<224; dy++)
3792 {
3793 1085952 si = start;
3794 1085952 di = &(framebuf->line[y+dy][0]);
3795 1085952 i = xstep;
3796 1085952 firstx = 1;
3797
3798
2/2
✓ Branch 0 taken 278003712 times.
✓ Branch 1 taken 1085952 times.
279089664 for(dx=0; dx<256; dx++)
3799 {
3800 278003712 *(di++) = *si;
3801
3802
2/2
✓ Branch 0 taken 234248896 times.
✓ Branch 1 taken 43754816 times.
278003712 if(++i >= fuzz)
3803 {
3804
2/2
✓ Branch 0 taken 42668864 times.
✓ Branch 1 taken 1085952 times.
43754816 if(!firstx)
3805 42668864 si += fuzz;
3806 else
3807 {
3808 1085952 si += fuzz-xstep;
3809 1085952 firstx = 0;
3810 }
3811
3812 43754816 i = 0;
3813 43754816 }
3814 278003712 }
3815 1085952 }
3816
3817
2/2
✓ Branch 0 taken 170084 times.
✓ Branch 1 taken 4848 times.
174932 if(!firsty)
3818 170084 y += fuzz;
3819 else
3820 {
3821 4848 y += ystep;
3822 4848 ystep = fuzz;
3823 4848 firsty = 0;
3824 }
3825 }
3826 4848 }
3827
3828 9285490 void updatescr(bool allowwavy)
3829 {
3830
4/6
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 9285376 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 114 times.
✓ Branch 4 taken 114 times.
✗ Branch 5 not taken.
9285490 static BITMAP *wavybuf = create_bitmap_ex(8,256,224);
3831
4/6
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 9285376 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 114 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 114 times.
9285490 static BITMAP *panorama = create_bitmap_ex(8,256,224);
3832
3833
2/2
✓ Branch 0 taken 9258725 times.
✓ Branch 1 taken 26765 times.
9285490 if(toogam)
3834 {
3835 26765 textout_ex(framebuf,font,"no walls",8,216,1,-1);
3836 26765 }
3837
3838
1/2
✓ Branch 0 taken 9285490 times.
✗ Branch 1 not taken.
9285490 if(Showpal)
3839 dump_pal(framebuf);
3840
3841
2/2
✓ Branch 0 taken 8984258 times.
✓ Branch 1 taken 301232 times.
9285490 if(!Playing)
3842 301232 black_opening_count=0;
3843
3844
2/2
✓ Branch 0 taken 9212296 times.
✓ Branch 1 taken 73194 times.
9285490 if(black_opening_count<0) //shape is opening up
3845 {
3846 73194 black_opening(framebuf,black_opening_x,black_opening_y,(66+black_opening_count),66);
3847
3848
2/4
✓ Branch 0 taken 73194 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 73194 times.
73194 if(Advance||(!Paused))
3849 {
3850 73194 ++black_opening_count;
3851 73194 }
3852 73194 }
3853
2/2
✓ Branch 0 taken 9186160 times.
✓ Branch 1 taken 26136 times.
9212296 else if(black_opening_count>0) //shape is closing
3854 {
3855 26136 black_opening(framebuf,black_opening_x,black_opening_y,black_opening_count,66);
3856
3857
2/4
✓ Branch 0 taken 26136 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 26136 times.
26136 if(Advance||(!Paused))
3858 {
3859 26136 --black_opening_count;
3860 26136 }
3861 26136 }
3862
3863
3/4
✓ Branch 0 taken 9187665 times.
✓ Branch 1 taken 97825 times.
✓ Branch 2 taken 9187665 times.
✗ Branch 3 not taken.
9285490 if(black_opening_count==0&&black_opening_shape==bosFADEBLACK)
3864 {
3865 black_opening_shape = bosCIRCLE;
3866 memcpy(RAMpal, tempblackpal, PAL_SIZE*sizeof(RGB));
3867 refreshTints();
3868 refreshpal=true;
3869 }
3870
3871
2/2
✓ Branch 0 taken 9031292 times.
✓ Branch 1 taken 254198 times.
9285490 if(refreshpal)
3872 {
3873 254198 refreshpal=false;
3874 254198 RAMpal[253] = _RGB(0,0,0);
3875 254198 RAMpal[254] = _RGB(63,63,63);
3876 254198 hw_palette = &RAMpal;
3877 254198 update_hw_pal = true;
3878
3879 254198 create_rgb_table(&rgb_table, RAMpal, NULL);
3880 254198 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
3881 254198 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
3882
3883
2/2
✓ Branch 0 taken 65074688 times.
✓ Branch 1 taken 254198 times.
65328886 for(int32_t q=0; q<PAL_SIZE; q++)
3884 {
3885 65074688 trans_table2.data[0][q] = q;
3886 65074688 trans_table2.data[q][q] = q;
3887 65074688 }
3888 254198 }
3889
3890 9285490 bool clearwavy = (wavy <= 0);
3891
3892
2/2
✓ Branch 0 taken 7655 times.
✓ Branch 1 taken 9277835 times.
9285490 if(wavy <= 0)
3893 {
3894 // So far one thing can alter wavy apart from scripts: Wavy DMaps.
3895 9277835 wavy = (DMaps[currdmap].flags&dmfWAVY ? 4 : 0);
3896 9277835 }
3897
3898 9285490 blit(framebuf, wavybuf, 0, 0, 0, 0, 256, 224);
3899
3900
6/6
✓ Branch 0 taken 31361 times.
✓ Branch 1 taken 9254129 times.
✓ Branch 2 taken 31239 times.
✓ Branch 3 taken 122 times.
✓ Branch 4 taken 128 times.
✓ Branch 5 taken 31111 times.
9285490 if(wavy && Playing && allowwavy)
3901 {
3902 31111 draw_wavy(framebuf, wavybuf, wavy,false);
3903 31111 }
3904
3905
2/2
✓ Branch 0 taken 9277835 times.
✓ Branch 1 taken 7655 times.
9285490 if(clearwavy)
3906 9277835 wavy = 0; // Wavy was set by a DMap flag. Clear it.
3907
2/4
✓ Branch 0 taken 7655 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7655 times.
7655 else if(Playing && !Paused)
3908 7655 wavy--; // Wavy was set by a script. Decrement it.
3909
3910
5/6
✓ Branch 0 taken 8984258 times.
✓ Branch 1 taken 301232 times.
✓ Branch 2 taken 259415 times.
✓ Branch 3 taken 8724843 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 259415 times.
9285490 if(Playing && msgpos && !screenscrolling)
3911 {
3912
1/2
✓ Branch 0 taken 259415 times.
✗ Branch 1 not taken.
259415 if(!(msg_bg_display_buf->clip))
3913 259415 blit_msgstr_bg(framebuf,0,0,0,playing_field_offset,256,168);
3914
1/2
✓ Branch 0 taken 259415 times.
✗ Branch 1 not taken.
259415 if(!(msg_portrait_display_buf->clip))
3915 259415 blit_msgstr_prt(framebuf,0,0,0,playing_field_offset,256,168);
3916
1/2
✓ Branch 0 taken 259415 times.
✗ Branch 1 not taken.
259415 if(!(msg_txt_display_buf->clip))
3917 259415 blit_msgstr_fg(framebuf,0,0,0,playing_field_offset,256,168);
3918 259415 }
3919
3920 /*
3921 if(!(msg_txt_display_buf->clip) && Playing && msgpos && !screenscrolling)
3922 {
3923 BITMAP* subBmp = 0;
3924 masked_blit(msg_txt_display_buf,subBmp,0,0,0,playing_field_offset,256,168);
3925 // masked_blit(msg_txt_display_buf,subBmp,0,playing_field_offset,256,168);
3926 draw_trans_sprite(framebuf, subBmp, 0, playing_field_offset);
3927 destroy_bitmap(subBmp);
3928 //void draw_sprite_ex(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t mode, int32_t flip);
3929 // masked_blit(msg_txt_display_buf,framebuf,0,0,0,playing_field_offset,256,168);
3930 //void masked_blit(BITMAP *source, BITMAP *dest, int32_t source_x, int32_t source_y, int32_t dest_x, int32_t dest_y, int32_t width, int32_t height);
3931 }
3932 */
3933
3934
2/2
✓ Branch 0 taken 9244433 times.
✓ Branch 1 taken 41057 times.
9285490 bool nosubscr = (tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET));
3935
3936
2/2
✓ Branch 0 taken 9249058 times.
✓ Branch 1 taken 36432 times.
9285490 if(nosubscr)
3937 {
3938 36432 rectfill(panorama,0,0,255,passive_subscreen_height/2,0);
3939 36432 rectfill(panorama,0,168+passive_subscreen_height/2,255,168+passive_subscreen_height-1,0);
3940 36432 blit(wavybuf,panorama,0,playing_field_offset,0,passive_subscreen_height/2,256,224-passive_subscreen_height);
3941 36432 }
3942
3943 //TODO: Optimize blit 'overcalls' -Gleeok
3944
2/2
✓ Branch 0 taken 36432 times.
✓ Branch 1 taken 9249058 times.
9285490 BITMAP *source = nosubscr ? panorama : wavybuf;
3945 9285490 blit(source,framebuf,0,0,0,0,256,224);
3946
3947 9285490 update_hw_screen();
3948 9285490 }
3949
3950 //----------------------------------------------------------------
3951
3952 static PALETTE syspal;
3953 int32_t onGUISnapshot()
3954 {
3955 char buf[200];
3956 int32_t num=0;
3957 bool realpal=(key[KEY_ZC_LCONTROL] || key[KEY_ZC_RCONTROL]);
3958 do
3959 {
3960 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
3961 }
3962 while(num<99999 && exists(buf));
3963
3964 BITMAP *b = create_bitmap_ex(8,resx,resy);
3965
3966 if(b)
3967 {
3968 blit(screen,b,0,0,0,0,resx,resy);
3969 save_bitmap(buf,b,RAMpal);
3970 destroy_bitmap(b);
3971 }
3972
3973 return D_O_K;
3974 }
3975
3976 int32_t onNonGUISnapshot()
3977 {
3978 PALETTE temppal;
3979 get_palette(temppal);
3980 bool realpal=(zc_getkey(KEY_ZC_LCONTROL, true) || zc_getkey(KEY_ZC_RCONTROL, true));
3981
3982 char buf[200];
3983 int32_t num=0;
3984
3985 do
3986 {
3987 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
3988 }
3989 while(num<99999 && exists(buf));
3990
3991 save_bitmap(buf,framebuf,realpal?temppal:RAMpal);
3992
3993 return D_O_K;
3994 }
3995
3996 int32_t onSnapshot()
3997 {
3998 if(zc_getkey(KEY_LSHIFT, true)||zc_getkey(KEY_RSHIFT, true))
3999 {
4000 onGUISnapshot();
4001 }
4002 else
4003 {
4004 onNonGUISnapshot();
4005 }
4006
4007 return D_O_K;
4008 }
4009
4010 int32_t onSaveMapPic()
4011 {
4012 int32_t mapres2 = 0;
4013 char buf[200];
4014 int32_t num=0;
4015 mapscr tmpscr_b[2];
4016 mapscr tmpscr_c[6];
4017 BITMAP* _screen_draw_buffer = NULL;
4018 _screen_draw_buffer = create_bitmap_ex(8,256,224);
4019 set_clip_state(_screen_draw_buffer,1);
4020
4021 for(int32_t i=0; i<6; ++i)
4022 {
4023 tmpscr_c[i] = tmpscr2[i];
4024 tmpscr2[i].zero_memory();
4025
4026 if(i>=2)
4027 {
4028 continue;
4029 }
4030
4031 tmpscr_b[i] = tmpscr[i];
4032 tmpscr[i].zero_memory();
4033 }
4034
4035 do
4036 {
4037 sprintf(buf, "%szc_screen%05d.png", get_snap_str(), ++num);
4038 }
4039 while(num<99999 && exists(buf));
4040
4041 BITMAP* mappic = NULL;
4042
4043
4044 bool done=false, redraw=true;
4045
4046 mappic = create_bitmap_ex(8,(256*16)>>mapres,(176*8)>>mapres);
4047
4048 if(!mappic)
4049 {
4050 enter_sys_pal();
4051 jwin_alert("View Map","Not enough memory.",NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
4052 exit_sys_pal();
4053 return D_O_K;;
4054 }
4055
4056 // draw the map
4057 set_clip_rect(_screen_draw_buffer, 0, 0, _screen_draw_buffer->w, _screen_draw_buffer->h);
4058
4059 for(int32_t y=0; y<8; y++)
4060 {
4061 for(int32_t x=0; x<16; x++)
4062 {
4063 if(!displayOnMap(x, y))
4064 {
4065 rectfill(_screen_draw_buffer, 0, 0, 255, 223, WHITE);
4066 }
4067 else
4068 {
4069 int32_t s = (y<<4) + x;
4070 loadscr2(1,s,-1);
4071
4072 for(int32_t i=0; i<6; i++)
4073 {
4074 if(tmpscr[1].layermap[i]<=0)
4075 continue;
4076
4077 if((ZCMaps[tmpscr[1].layermap[i]-1].tileWidth==ZCMaps[currmap].tileWidth) &&
4078 (ZCMaps[tmpscr[1].layermap[i]-1].tileHeight==ZCMaps[currmap].tileHeight))
4079 {
4080 const int32_t _mapsSize = (ZCMaps[currmap].tileWidth)*(ZCMaps[currmap].tileHeight);
4081
4082 tmpscr2[i]=TheMaps[(tmpscr[1].layermap[i]-1)*MAPSCRS+tmpscr[1].layerscreen[i]];
4083 }
4084 }
4085
4086 if(XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
4087
4088 if(XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
4089
4090 if(lenscheck(tmpscr+1,0)) putscr(_screen_draw_buffer,256,0,tmpscr+1);
4091 do_layer(_screen_draw_buffer, 0, 1, tmpscr+1, -256, playing_field_offset, 2);
4092
4093 if(!XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
4094
4095 putscrdoors(_screen_draw_buffer,256,0,tmpscr+1);
4096 if(get_qr(qr_PUSHBLOCK_SPRITE_LAYER))
4097 {
4098 do_layer(_screen_draw_buffer, -2, 0, tmpscr+1, -256, playing_field_offset, 2);
4099 if(get_qr(qr_PUSHBLOCK_LAYER_1_2))
4100 {
4101 do_layer(_screen_draw_buffer, -2, 1, tmpscr+1, -256, playing_field_offset, 2);
4102 do_layer(_screen_draw_buffer, -2, 2, tmpscr+1, -256, playing_field_offset, 2);
4103 }
4104 }
4105 do_layer(_screen_draw_buffer, -3, 0, tmpscr+1, -256, playing_field_offset, 2); // Freeform combos!
4106
4107 if(!XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
4108
4109 do_layer(_screen_draw_buffer, 0, 4, tmpscr+1, -256, playing_field_offset, 2);
4110 do_layer(_screen_draw_buffer, -1, 0, tmpscr+1, -256, playing_field_offset, 2);
4111 if(get_qr(qr_OVERHEAD_COMBOS_L1_L2))
4112 {
4113 do_layer(_screen_draw_buffer, -1, 1, tmpscr+1, -256, playing_field_offset, 2);
4114 do_layer(_screen_draw_buffer, -1, 2, tmpscr+1, -256, playing_field_offset, 2);
4115 }
4116 do_layer(_screen_draw_buffer, 0, 5, tmpscr+1, -256, playing_field_offset, 2);
4117 do_layer(_screen_draw_buffer, 0, 6, tmpscr+1, -256, playing_field_offset, 2);
4118
4119 }
4120
4121 stretch_blit(_screen_draw_buffer, mappic, 256, 0, 256, 176, x<<(8-mapres), (y*176)>>mapres, 256>>mapres, 176>>mapres);
4122 }
4123 }
4124
4125 for(int32_t i=0; i<6; ++i)
4126 {
4127 tmpscr2[i]=tmpscr_c[i];
4128
4129 if(i>=2)
4130 {
4131 continue;
4132 }
4133
4134 tmpscr[i]=tmpscr_b[i];
4135 }
4136
4137 save_bitmap(buf,mappic,RAMpal);
4138 destroy_bitmap(mappic);
4139 destroy_bitmap(_screen_draw_buffer);
4140 return D_O_K;
4141 }
4142
4143 14 void f_Quit(int32_t type)
4144 {
4145
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
14 if(type==qQUIT && !Playing)
4146 return;
4147
4148 14 bool from_menu = is_sys_pal;
4149
4150
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(!from_menu)
4151 {
4152 14 music_pause();
4153 14 pause_all_sfx();
4154 14 sys_mouse();
4155 14 }
4156 14 enter_sys_pal();
4157 14 clear_keybuf();
4158
4159
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 13 times.
14 if (replay_version_check(0, 10))
4160 13 replay_poll();
4161
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if (replay_is_replaying())
4162 14 replay_peek_quit();
4163
4164
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if (!replay_is_replaying())
4165 switch(type)
4166 {
4167 case qQUIT:
4168 onQuit();
4169 break;
4170
4171 case qRESET:
4172 onReset();
4173 break;
4174
4175 case qEXIT:
4176 onExit();
4177 break;
4178 }
4179
4180
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(Quit)
4181 {
4182 14 kill_sfx();
4183 14 music_stop();
4184 14 exit_sys_pal();
4185 14 update_hw_screen();
4186 14 }
4187 else
4188 {
4189 exit_sys_pal();
4190 if(!from_menu)
4191 {
4192 music_resume();
4193 resume_all_sfx();
4194 }
4195 }
4196
4197
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(!from_menu)
4198 14 game_mouse();
4199 14 eat_buttons();
4200
4201 14 zc_readrawkey(KEY_ESC);
4202
4203 14 zc_readrawkey(KEY_ENTER);
4204 14 }
4205
4206 //----------------------------------------------------------------
4207
4208 int32_t onNoWalls()
4209 {
4210 cheats_enqueue(Cheat::Walls);
4211 return D_O_K;
4212 }
4213
4214 int32_t onIgnoreSideview()
4215 {
4216 cheats_enqueue(Cheat::IgnoreSideView);
4217 return D_O_K;
4218 }
4219
4220 9285364 int32_t input_idle(bool checkmouse)
4221 {
4222 static int32_t mx, my, mz, mb;
4223
4224
4/6
✓ Branch 0 taken 9285364 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2461556 times.
✓ Branch 3 taken 6823808 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2461556 times.
11746920 if(keypressed() || zc_key_pressed() ||
4225
4/8
✓ Branch 0 taken 2461556 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2461556 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2461556 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2461556 times.
✗ Branch 7 not taken.
2461556 (checkmouse && (mx != mouse_x || my != mouse_y || mz != mouse_z || mb != mouse_b)))
4226 {
4227 6823808 idle_count = 0;
4228
4229
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6823808 times.
6823808 if(active_count < MAX_ACTIVE)
4230 {
4231 6823808 ++active_count;
4232 6823808 }
4233 6823808 }
4234
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2461556 times.
2461556 else if(idle_count < MAX_IDLE)
4235 {
4236 2461556 ++idle_count;
4237 2461556 active_count = 0;
4238 2461556 }
4239
4240 9285364 mx = mouse_x;
4241 9285364 my = mouse_y;
4242 9285364 mz = mouse_z;
4243 9285364 mb = mouse_b;
4244
4245 9285364 return idle_count;
4246 }
4247
4248 int32_t onGoFast()
4249 {
4250 cheats_enqueue(Cheat::Fast);
4251 return D_O_K;
4252 }
4253
4254 int32_t onKillCheat()
4255 {
4256 cheats_enqueue(Cheat::Kill);
4257 return D_O_K;
4258 }
4259
4260 int32_t onSecretsCheat()
4261 {
4262 cheats_enqueue(Cheat::TrigSecrets);
4263 return D_O_K;
4264 }
4265 int32_t onSecretsCheatPerm()
4266 {
4267 cheats_enqueue(Cheat::TrigSecretsPerm);
4268 return D_O_K;
4269 }
4270
4271 int32_t onShowLayer0()
4272 {
4273 show_layer_0 = !show_layer_0;
4274 return D_O_K;
4275 }
4276 int32_t onShowLayer1()
4277 {
4278 show_layer_1 = !show_layer_1;
4279 return D_O_K;
4280 }
4281 int32_t onShowLayer2()
4282 {
4283 show_layer_2 = !show_layer_2;
4284 return D_O_K;
4285 }
4286 int32_t onShowLayer3()
4287 {
4288 show_layer_3 = !show_layer_3;
4289 return D_O_K;
4290 }
4291 int32_t onShowLayer4()
4292 {
4293 show_layer_4 = !show_layer_4;
4294 return D_O_K;
4295 }
4296 int32_t onShowLayer5()
4297 {
4298 show_layer_5 = !show_layer_5;
4299 return D_O_K;
4300 }
4301 int32_t onShowLayer6()
4302 {
4303 show_layer_6 = !show_layer_6;
4304 return D_O_K;
4305 }
4306 int32_t onShowLayerO()
4307 {
4308 show_layer_over=!show_layer_over;
4309 return D_O_K;
4310 }
4311 int32_t onShowLayerP()
4312 {
4313 show_layer_push=!show_layer_push;
4314 return D_O_K;
4315 }
4316 int32_t onShowLayerS()
4317 {
4318 show_sprites=!show_sprites;
4319 return D_O_K;
4320 }
4321 int32_t onShowLayerF()
4322 {
4323 show_ffcs=!show_ffcs;
4324 return D_O_K;
4325 }
4326 int32_t onShowLayerW()
4327 {
4328 show_walkflags=!show_walkflags;
4329 if(show_walkflags)
4330 show_effectflags = false;
4331 return D_O_K;
4332 }
4333 int32_t onShowLayerE()
4334 {
4335 show_effectflags=!show_effectflags;
4336 if(show_effectflags)
4337 show_walkflags = false;
4338 return D_O_K;
4339 }
4340 int32_t onShowFFScripts()
4341 {
4342 show_ff_scripts=!show_ff_scripts;
4343 return D_O_K;
4344 }
4345 int32_t onShowHitboxes()
4346 {
4347 show_hitboxes=!show_hitboxes;
4348 return D_O_K;
4349 }
4350 int32_t onShowInfoOpacity()
4351 {
4352 info_opacity = vbound(getnumber("Debug Info Opacity",info_opacity),0,255);
4353 zc_set_config("zc","debug_info_opacity",info_opacity);
4354 return D_O_K;
4355 }
4356
4357 int32_t onLightSwitch()
4358 {
4359 cheats_enqueue(Cheat::Light);
4360 return D_O_K;
4361 }
4362
4363 int32_t onGoTo();
4364 int32_t onGoToComplete();
4365
4366 9285364 void syskeys()
4367 {
4368 9285364 update_system_keys();
4369
4370 int32_t oldtitle_version;
4371
4372
1/2
✓ Branch 0 taken 9285364 times.
✗ Branch 1 not taken.
9285364 if(close_button_quit)
4373 {
4374 close_button_quit=false;
4375 f_Quit(qEXIT);
4376 }
4377
4378 9285364 poll_joystick();
4379
4380
2/10
✓ Branch 0 taken 9285364 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 9285364 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
9285364 if(rMbtn() || (gui_mouse_b() && !mouse_down && ClickToFreeze &&!disableClickToFreeze))
4381 {
4382 oldtitle_version=title_version;
4383 System();
4384 }
4385
4386 9285364 mouse_down=gui_mouse_b();
4387
4388
1/2
✓ Branch 0 taken 9285364 times.
✗ Branch 1 not taken.
9285364 if(zc_read_system_key(KEY_F1))
4389 {
4390 if(zc_get_system_key(KEY_ZC_LCONTROL) || zc_get_system_key(KEY_ZC_RCONTROL))
4391 {
4392 halt=!halt;
4393 //zinit.subscreen=(zinit.subscreen+1)%ssdtMAX;
4394 }
4395 else
4396 {
4397 Throttlefps=!Throttlefps;
4398 zc_set_config(cfg_sect,"throttlefps", (int32_t)Throttlefps);
4399 }
4400 }
4401
4402 // if(zc_readkey(KEY_F1)) Vsync=!Vsync;
4403 /*
4404 if(zc_readkey(KEY_F1)) set_bit(QHeader.rules4,qr4_NEWENEMYTILES,
4405 1-((get_bit(QHeader.rules4,qr4_NEWENEMYTILES))));
4406 */
4407
4408
1/2
✓ Branch 0 taken 9285364 times.
✗ Branch 1 not taken.
9285364 if(zc_read_system_key(KEY_F2))
4409 {
4410 ShowFPS=!ShowFPS;
4411 zc_set_config(cfg_sect,"showfps",(int32_t)ShowFPS);
4412 }
4413
4414
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9285364 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9285364 if(zc_read_system_key(KEY_F3) && Playing) Paused=!Paused;
4415
4416
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9285364 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9285364 if(zc_read_system_key(KEY_F4) && Playing)
4417 {
4418 Paused=true;
4419 Advance=true;
4420 }
4421
4422
1/2
✓ Branch 0 taken 9285364 times.
✗ Branch 1 not taken.
9285364 if(zc_read_system_key(KEY_F6)) onTryQuit();
4423
4424 #ifndef ALLEGRO_MACOSX
4425
1/2
✓ Branch 0 taken 9285364 times.
✗ Branch 1 not taken.
9285364 if(zc_read_system_key(KEY_F9)) f_Quit(qRESET);
4426
4427
1/2
✓ Branch 0 taken 9285364 times.
✗ Branch 1 not taken.
9285364 if(zc_read_system_key(KEY_F10)) f_Quit(qEXIT);
4428 #else
4429 if(zc_read_system_key(KEY_F7)) f_Quit(qRESET);
4430
4431 if(zc_read_system_key(KEY_F8)) f_Quit(qEXIT);
4432 #endif
4433
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 9285364 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
9285364 if(zc_read_system_key(KEY_F5)&&(Playing && currscr<128 && DMaps[currdmap].flags&dmfVIEWMAP)) onSaveMapPic();
4434
4435
1/2
✓ Branch 0 taken 9285364 times.
✗ Branch 1 not taken.
9285364 if (zc_read_system_key(KEY_F12))
4436 {
4437 onSnapshot();
4438 }
4439
4440
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9285364 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9285364 if(debug_enabled && zc_read_system_key(KEY_TAB))
4441 set_debug(!get_debug());
4442
4443
1/2
✓ Branch 0 taken 9285364 times.
✗ Branch 1 not taken.
9285364 if(CheatModifierKeys())
4444 {
4445 for(Cheat c = (Cheat)1; c < Cheat::Last; c = (Cheat)(c+1))
4446 {
4447 if(!bindable_cheat(c))
4448 continue;
4449 if(get_debug() || cheat >= cheat_lvl(c))
4450 {
4451 if(checkcheat(c))
4452 cheats_hit_bind(c);
4453 }
4454 }
4455 }
4456
4457
1/2
✓ Branch 0 taken 9285364 times.
✗ Branch 1 not taken.
9285364 if(volkeys)
4458 {
4459 if(zc_read_system_key(KEY_PGUP)) master_volume(-1,midi_volume+8);
4460
4461 if(zc_read_system_key(KEY_PGDN)) master_volume(-1,midi_volume==255?248:midi_volume-8);
4462
4463 if(zc_read_system_key(KEY_HOME)) master_volume(digi_volume+8,-1);
4464
4465 if(zc_read_system_key(KEY_END)) master_volume(digi_volume==255?248:digi_volume-8,-1);
4466 }
4467
4468
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 9285364 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
9285364 if(!get_debug() || !SystemKeys || replay_is_replaying())
4469 9285364 goto bottom;
4470
4471 if(zc_readkey(KEY_D))
4472 {
4473 details = !details;
4474 rectfill(screen,0,0,319,7,BLACK);
4475 rectfill(screen,0,8,31,239,BLACK);
4476 rectfill(screen,288,8,319,239,BLACK);
4477 rectfill(screen,32,232,287,239,BLACK);
4478 }
4479
4480 if(zc_readkey(KEY_P)) Paused=!Paused;
4481
4482 //if(zc_readkey(KEY_P)) centerHero();
4483 if(zc_readkey(KEY_A))
4484 {
4485 Paused=true;
4486 Advance=true;
4487 }
4488
4489 if(zc_readkey(KEY_G)) db=(db==999)?0:999;
4490 #ifndef ALLEGRO_MACOSX
4491 if(zc_readkey(KEY_F8)) Showpal=!Showpal;
4492
4493 if(zc_readkey(KEY_F7))
4494 {
4495 Matrix(ss_speed, ss_density, 0);
4496 game_pal();
4497 }
4498 #else
4499 // The reason these are different on Mac in the first place is that
4500 // the OS doesn't let us use F9 and F10...
4501 if(zc_readkey(KEY_F10)) Showpal=!Showpal;
4502
4503 if(zc_readkey(KEY_F9))
4504 {
4505 Matrix(ss_speed, ss_density, 0);
4506 game_pal();
4507 }
4508 #endif
4509 if(zc_readkey(KEY_PLUS_PAD) || zc_readkey(KEY_EQUALS))
4510 {
4511 //change containers
4512 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4513 {
4514 //magic containers
4515 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4516 {
4517 game->set_maxmagic(zc_min(game->get_maxmagic()+game->get_mp_per_block(),game->get_mp_per_block()*8));
4518 }
4519 else
4520 {
4521 game->set_maxlife(zc_min(game->get_maxlife()+game->get_hp_per_heart(),game->get_hp_per_heart()*24));
4522 }
4523 }
4524 else
4525 {
4526 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4527 {
4528 game->set_magic(zc_min(game->get_magic()+1,game->get_maxmagic()));
4529 }
4530 else
4531 {
4532 game->set_life(zc_min(game->get_life()+1,game->get_maxlife()));
4533 }
4534 }
4535 }
4536
4537 if(zc_readkey(KEY_MINUS_PAD) || zc_readkey(KEY_MINUS))
4538 {
4539 //change containers
4540 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4541 {
4542 //magic containers
4543 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4544 {
4545 game->set_maxmagic(zc_max(game->get_maxmagic()-game->get_mp_per_block(),0));
4546 game->set_magic(zc_min(game->get_maxmagic(), game->get_magic()));
4547 //heart containers
4548 }
4549 else
4550 {
4551 game->set_maxlife(zc_max(game->get_maxlife()-game->get_hp_per_heart(),game->get_hp_per_heart()));
4552 game->set_life(zc_min(game->get_maxlife(), game->get_life()));
4553 }
4554 }
4555 else
4556 {
4557 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4558 {
4559 game->set_magic(zc_max(game->get_magic()-1,0));
4560 }
4561 else
4562 {
4563 game->set_life(zc_max(game->get_life()-1,0));
4564 }
4565 }
4566 }
4567
4568 if(zc_readkey(KEY_COMMA)) jukebox(currmidi-1);
4569
4570 if(zc_readkey(KEY_STOP)) jukebox(currmidi+1);
4571
4572 verifyBothWeapons();
4573
4574 bottom:
4575
4576
1/2
✓ Branch 0 taken 9285364 times.
✗ Branch 1 not taken.
9285364 if(input_idle(true) > after_time())
4577 {
4578 Matrix(ss_speed, ss_density, 0);
4579 game_pal();
4580 }
4581 9285364 }
4582
4583 705770 void checkQuitKeys()
4584 {
4585 #ifndef ALLEGRO_MACOSX
4586
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 705770 times.
705770 if(key[KEY_F9]) f_Quit(qRESET);
4587
4588
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 705770 times.
705770 if(key[KEY_F10]) f_Quit(qEXIT);
4589 #else
4590 if(key[KEY_F7]) f_Quit(qRESET);
4591
4592 if(key[KEY_F8]) f_Quit(qEXIT);
4593 #endif
4594 705770 }
4595
4596 9285364 bool CheatModifierKeys()
4597 {
4598 // Cheats are replayed via the X cheat step, no need to check for keyboard input
4599 // to trigger cheats.
4600
1/2
✓ Branch 0 taken 9285364 times.
✗ Branch 1 not taken.
9285364 if (replay_is_replaying())
4601 9285364 return false;
4602
4603 if ( ( cheat_modifier_keys[0] > 0 && key[cheat_modifier_keys[0]] ) ||
4604 ( cheat_modifier_keys[1] > 0 && key[cheat_modifier_keys[1]] ) ||
4605 (cheat_modifier_keys[0] <= 0 && cheat_modifier_keys[1] <= 0))
4606 {
4607 if ( ( cheat_modifier_keys[2] <= 0 || key[cheat_modifier_keys[2]] ) ||
4608 ( cheat_modifier_keys[3] > 0 && key[cheat_modifier_keys[3]] ) ||
4609 (cheat_modifier_keys[2] <= 0 && cheat_modifier_keys[3] <= 0))
4610 {
4611 return true;
4612 }
4613 }
4614 return false;
4615 9285364 }
4616
4617 //99:05:54, for some reason?
4618 #define OLDMAXTIME 21405240
4619 //9000:00:00, the highest even-thousand hour fitting within 32b signed. This is 375 *DAYS*.
4620 #define MAXTIME 1944000000
4621
4622 9285490 void advanceframe(bool allowwavy, bool sfxcleanup, bool allowF6Script)
4623 {
4624
2/2
✓ Branch 0 taken 9165367 times.
✓ Branch 1 taken 120123 times.
9285490 if(zcmusic!=NULL)
4625 {
4626 120123 zcmusic_poll();
4627 120123 }
4628 9285490 zcmixer_update(zcmixer, emusic_volume, FFCore.usr_music_volume, get_qr(qr_OLD_SCRIPT_VOLUME));
4629
4630 9285490 updatescr(allowwavy);
4631
4632 9285490 Advance=false;
4633
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 9285490 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 9285490 times.
9285490 while(Paused && !Advance && !Quit)
4634 {
4635 // have to call this, otherwise we'll get an infinite loop
4636 syskeys();
4637 if(allowF6Script)
4638 {
4639 FFCore.runF6Engine();
4640 }
4641 throttleFPS();
4642
4643 #ifdef _WIN32
4644
4645 if(use_dwm_flush)
4646 {
4647 do_DwmFlush();
4648 }
4649
4650 #endif
4651
4652 // to keep music playing
4653 if(zcmusic!=NULL)
4654 {
4655 zcmusic_poll();
4656 }
4657
4658 update_hw_screen();
4659 }
4660
4661
2/2
✓ Branch 0 taken 9285378 times.
✓ Branch 1 taken 112 times.
9285490 if(Quit)
4662 112 return;
4663
4664
3/4
✓ Branch 0 taken 8984249 times.
✓ Branch 1 taken 301129 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8984249 times.
9285378 if(Playing && game->get_time()<unsigned(get_qr(qr_GREATER_MAX_TIME) ? MAXTIME : OLDMAXTIME))
4665 8984249 game->change_time(1);
4666
4667 // Many mistakes have been make re: inputs, and we are stuck with many replays relying on those mistakes.
4668
4669 9285378 bool should_reset_down_state = !get_qr(qr_BROKEN_INPUT_DOWN_STATE);
4670
2/2
✓ Branch 0 taken 19691 times.
✓ Branch 1 taken 9265687 times.
9285378 if (replay_version_check(0, 16))
4671 9265687 should_reset_down_state = replay_version_check(11, 16);
4672
2/2
✓ Branch 0 taken 6948570 times.
✓ Branch 1 taken 2336808 times.
9285378 if (should_reset_down_state)
4673 {
4674
2/2
✓ Branch 0 taken 42062544 times.
✓ Branch 1 taken 2336808 times.
44399352 for (int i = 0; i < ZC_CONTROL_STATES; i++)
4675 42062544 down_control_states[i] = raw_control_state[i];
4676 2336808 }
4677
4678
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 9285364 times.
9285378 if (replay_is_active())
4679 {
4680
2/2
✓ Branch 0 taken 1270449 times.
✓ Branch 1 taken 8014915 times.
9285364 if (replay_version_check(3))
4681 8014915 replay_poll();
4682
4683
4/4
✓ Branch 0 taken 6944988 times.
✓ Branch 1 taken 2340376 times.
✓ Branch 2 taken 100535 times.
✓ Branch 3 taken 6844453 times.
9285364 if (replay_version_check(11) || replay_version_check(6, 8))
4684 2440911 replay_peek_input();
4685 9285364 }
4686
4687 9285378 load_control_called_this_frame = false;
4688
4689 9285378 poll_keyboard();
4690 9285378 update_keys();
4691
4692 9285378 ++frame;
4693
4694
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 9285364 times.
9285378 if (replay_is_replaying())
4695 9285364 replay_do_cheats();
4696 9285378 syskeys();
4697
4698 // The mouse variables can change from the mouse thread at anytime during a frame,
4699 // so save the result at the start so that replaying is consistent.
4700 9285378 script_mouse_x = gui_mouse_x();
4701 9285378 script_mouse_y = gui_mouse_y();
4702 9285378 script_mouse_z = mouse_z;
4703 9285378 script_mouse_b = mouse_b;
4704
4705 // Cheats used via the System menu (called by syskeys) will call cheats_enqueue. syskeys
4706 // is called just above, and in the paused loop above, so the queue-and-defer-slightly
4707 // approach here means it doesn't matter which call adds the cheat.
4708 9285378 cheats_execute_queued();
4709
4710
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 9285364 times.
9285378 if (replay_is_replaying())
4711 9285364 replay_peek_quit();
4712
2/2
✓ Branch 0 taken 9285364 times.
✓ Branch 1 taken 14 times.
9285378 if (GameFlags & GAMEFLAG_TRYQUIT)
4713 14 replay_step_quit(0);
4714
2/2
✓ Branch 0 taken 2934 times.
✓ Branch 1 taken 9282444 times.
9285378 if(allowF6Script)
4715 9282444 FFCore.runF6Engine();
4716
2/2
✓ Branch 0 taken 9285080 times.
✓ Branch 1 taken 298 times.
9285378 if (Quit)
4717 298 replay_step_quit(Quit);
4718 // Someday... maybe install a Turbo button here?
4719 9285378 throttleFPS();
4720
4721 #ifdef _WIN32
4722
4723 if(use_dwm_flush)
4724 {
4725 do_DwmFlush();
4726 }
4727
4728 #endif
4729
4730 //textprintf_ex(screen,font,0,72,254,BLACK,"%d %d", lastentrance, lastentrance_dmap);
4731
2/2
✓ Branch 0 taken 68758 times.
✓ Branch 1 taken 9216620 times.
9285378 if(sfxcleanup)
4732 9216620 sfx_cleanup();
4733
4734 9285378 jit_poll();
4735
4736 #ifdef __EMSCRIPTEN__
4737 // Yield the main thread back to the browser occasionally.
4738 if (is_headless())
4739 {
4740 static int rate = 10000;
4741 static int force_yield = rate;
4742 if (force_yield++ >= rate)
4743 {
4744 force_yield = 0;
4745 emscripten_sleep(0);
4746 }
4747 }
4748 #endif
4749 9285490 }
4750
4751 101 void zapout()
4752 {
4753 101 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4754 101 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4755
4756 101 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4757 101 script_drawing_commands.Clear();
4758
4759 // zap out
4760
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 2424 times.
2525 for(int32_t i=1; i<=24; i++)
4761 {
4762 2424 draw_fuzzy(i);
4763 2424 advanceframe(true);
4764
4765
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2424 times.
2424 if(Quit)
4766 {
4767 break;
4768 }
4769 2424 }
4770 101 }
4771
4772 101 void zapin()
4773 {
4774 101 FFCore.warpScriptCheck();
4775 101 draw_screen(tmpscr);
4776 101 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4777 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
4778 101 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4779
4780 // zap out
4781 101 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4782
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 2424 times.
2525 for(int32_t i=24; i>=1; i--)
4783 {
4784 2424 draw_fuzzy(i);
4785 2424 advanceframe(true);
4786
4787
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2424 times.
2424 if(Quit)
4788 {
4789 break;
4790 }
4791 2424 }
4792 101 }
4793
4794
4795 65 void wavyout(bool showhero)
4796 {
4797 65 draw_screen(tmpscr, showhero);
4798 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
4799
4800 65 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4801 65 clear_to_color(wavebuf,0);
4802 65 blit(framebuf,wavebuf,0,0,16,0,256,224);
4803
4804 static PALETTE wavepal;
4805
4806 int32_t ofs;
4807 65 int32_t amplitude=8;
4808
4809 65 int32_t wavelength=4;
4810 65 double palpos=0, palstep=4, palstop=126;
4811
4812 65 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4813
2/2
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 2730 times.
2795 for(int32_t i=0; i<168; i+=wavelength)
4814 {
4815
2/2
✓ Branch 0 taken 698880 times.
✓ Branch 1 taken 2730 times.
701610 for(int32_t l=0; l<256; l++)
4816 {
4817 698880 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
4818 698880 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
4819 698880 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
4820 698880 }
4821
4822 2730 palpos+=palstep;
4823
4824
1/2
✓ Branch 0 taken 2730 times.
✗ Branch 1 not taken.
2730 if(palpos>=0)
4825 {
4826 2730 hw_palette = &wavepal;
4827 2730 update_hw_pal = true;
4828 2730 }
4829 else
4830 {
4831 hw_palette = &RAMpal;
4832 update_hw_pal = true;
4833 }
4834
4835
2/2
✓ Branch 0 taken 458640 times.
✓ Branch 1 taken 2730 times.
461370 for(int32_t j=0; j+playing_field_offset<224; j++)
4836 {
4837
2/2
✓ Branch 0 taken 117411840 times.
✓ Branch 1 taken 458640 times.
117870480 for(int32_t k=0; k<256; k++)
4838 {
4839 117411840 ofs=0;
4840
4841
4/4
✓ Branch 0 taken 57308160 times.
✓ Branch 1 taken 60103680 times.
✓ Branch 2 taken 28654080 times.
✓ Branch 3 taken 28654080 times.
117411840 if((j<i)&&(j&1))
4842 {
4843 28654080 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
4844 28654080 }
4845
4846 117411840 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
4847 117411840 }
4848 458640 }
4849
4850 2730 advanceframe(true);
4851
4852 // animate_combos();
4853
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2730 times.
2730 if(Quit)
4854 break;
4855 2730 }
4856
4857 65 destroy_bitmap(wavebuf);
4858 65 }
4859
4860 65 void wavyin()
4861 {
4862 65 draw_screen(tmpscr);
4863 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
4864
4865 65 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4866 65 clear_to_color(wavebuf,0);
4867 65 blit(framebuf,wavebuf,0,0,16,0,256,224);
4868
4869 static PALETTE wavepal;
4870
4871 //Breaks dark rooms.
4872 //In any case I don't think we need this, since palette is already loaded in doWarp() (famous last words...) -DD
4873 /*
4874 loadfullpal();
4875 loadlvlpal(DMaps[currdmap].color);
4876 ringcolor(false);
4877 */
4878 65 refreshpal=false;
4879 int32_t ofs;
4880 65 int32_t amplitude=8;
4881 65 int32_t wavelength=4;
4882 65 double palpos=168, palstep=4, palstop=126;
4883
4884 65 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4885
2/2
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 2730 times.
2795 for(int32_t i=0; i<168; i+=wavelength)
4886 {
4887
2/2
✓ Branch 0 taken 698880 times.
✓ Branch 1 taken 2730 times.
701610 for(int32_t l=0; l<256; l++)
4888 {
4889 698880 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
4890 698880 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
4891 698880 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
4892 698880 }
4893
4894 2730 palpos-=palstep;
4895
4896
1/2
✓ Branch 0 taken 2730 times.
✗ Branch 1 not taken.
2730 if(palpos>=0)
4897 {
4898 2730 hw_palette = &wavepal;
4899 2730 update_hw_pal = true;
4900 2730 }
4901 else
4902 {
4903 hw_palette = &RAMpal;
4904 update_hw_pal = true;
4905 }
4906
4907
2/2
✓ Branch 0 taken 458640 times.
✓ Branch 1 taken 2730 times.
461370 for(int32_t j=0; j+playing_field_offset<224; j++)
4908 {
4909
2/2
✓ Branch 0 taken 117411840 times.
✓ Branch 1 taken 458640 times.
117870480 for(int32_t k=0; k<256; k++)
4910 {
4911 117411840 ofs=0;
4912
4913
4/4
✓ Branch 0 taken 59404800 times.
✓ Branch 1 taken 58007040 times.
✓ Branch 2 taken 30051840 times.
✓ Branch 3 taken 29352960 times.
117411840 if((j<(167-i))&&(j&1))
4914 {
4915 29352960 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
4916 29352960 }
4917
4918 117411840 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
4919 117411840 }
4920 458640 }
4921
4922 2730 advanceframe(true);
4923 // animate_combos();
4924
4925
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2730 times.
2730 if(Quit)
4926 break;
4927 2730 }
4928
4929 65 destroy_bitmap(wavebuf);
4930 65 }
4931
4932 2168 void blackscr(int32_t fcnt,bool showsubscr)
4933 {
4934 2168 reset_pal_cycling();
4935 2168 script_drawing_commands.Clear();
4936
4937 2168 FFCore.warpScriptCheck();
4938 2168 bool showtime = game->should_show_time();
4939
2/2
✓ Branch 0 taken 2168 times.
✓ Branch 1 taken 64970 times.
67138 while(fcnt>0)
4940 {
4941 64970 clear_bitmap(framebuf);
4942
4943
2/2
✓ Branch 0 taken 25080 times.
✓ Branch 1 taken 39890 times.
64970 if(showsubscr)
4944 {
4945 39890 put_passive_subscr(framebuf,0,passive_subscreen_offset,showtime,sspUP);
4946
3/4
✓ Branch 0 taken 39890 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 750 times.
✓ Branch 3 taken 39140 times.
39890 if(get_qr(qr_SCRIPTDRAWSINWARPS) || (get_qr(qr_PASSIVE_SUBSCRIPT_RUNS_WHEN_GAME_IS_FROZEN)))
4947 {
4948 750 do_script_draws(framebuf, tmpscr, 0, playing_field_offset);
4949 750 }
4950 39890 }
4951
4952 64970 advanceframe(true);
4953
4954
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64970 times.
64970 if(Quit)
4955 break;
4956
4957 64970 --fcnt;
4958 }
4959 2168 }
4960
4961 1010 void openscreen(int32_t shape)
4962 {
4963 1010 reset_pal_cycling();
4964 1010 black_opening_count=0;
4965
4966
3/4
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 910 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 100 times.
1010 if(COOLSCROLL || shape>-1)
4967 {
4968 910 open_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
4969 910 return;
4970 }
4971 else
4972 {
4973 100 Hero.setDontDraw(true);
4974 100 show_subscreen_dmap_dots=false;
4975 100 show_subscreen_numbers=false;
4976 // show_subscreen_items=false;
4977 100 show_subscreen_life=false;
4978 }
4979
4980 100 int32_t x=128;
4981
4982 100 FFCore.warpScriptCheck();
4983
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 8000 times.
8100 for(int32_t i=0; i<80; i++)
4984 {
4985 8000 draw_screen(tmpscr);
4986 //? draw_screen already draws the subscreen -DD
4987 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
4988 8000 x=128-(((i*128/80)/8)*8);
4989
4990
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8000 times.
8000 if(x>0)
4991 {
4992 8000 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
4993 8000 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
4994 8000 }
4995
4996 8000 advanceframe(true);
4997
4998
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8000 times.
8000 if(Quit)
4999 {
5000 break;
5001 }
5002 8000 }
5003
5004 100 Hero.setDontDraw(false);
5005 100 show_subscreen_items=true;
5006 100 show_subscreen_dmap_dots=true;
5007 1010 }
5008
5009 void closescreen(int32_t shape)
5010 {
5011 reset_pal_cycling();
5012 black_opening_count=0;
5013
5014 if(COOLSCROLL || shape>-1)
5015 {
5016 close_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
5017 return;
5018 }
5019 else
5020 {
5021 Hero.setDontDraw(true);
5022 show_subscreen_dmap_dots=false;
5023 show_subscreen_numbers=false;
5024 // show_subscreen_items=false;
5025 show_subscreen_life=false;
5026 }
5027
5028 int32_t x=128;
5029
5030 FFCore.warpScriptCheck();
5031 for(int32_t i=79; i>=0; --i)
5032 {
5033 draw_screen(tmpscr);
5034 //? draw_screen already draws the subscreen -DD
5035 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
5036 x=128-(((i*128/80)/8)*8);
5037
5038 if(x>0)
5039 {
5040 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
5041 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
5042 }
5043
5044 advanceframe(true);
5045
5046 if(Quit)
5047 {
5048 break;
5049 }
5050 }
5051
5052 Hero.setDontDraw(false);
5053 show_subscreen_items=true;
5054 show_subscreen_dmap_dots=true;
5055 }
5056
5057 179 int32_t TriforceCount()
5058 {
5059 179 int32_t c=0;
5060
5061
2/2
✓ Branch 0 taken 1432 times.
✓ Branch 1 taken 179 times.
1611 for(int32_t i=1; i<=8; i++)
5062
2/2
✓ Branch 0 taken 388 times.
✓ Branch 1 taken 1044 times.
2476 if(game->lvlitems[i]&liTRIFORCE)
5063 1044 ++c;
5064
5065 179 return c;
5066 }
5067
5068 int32_t onCustomGame()
5069 {
5070 int32_t file = getsaveslot();
5071
5072 if(file < 0)
5073 return D_O_K;
5074
5075 bool ret = (custom_game(file)!=0);
5076 return ret ? D_CLOSE : D_O_K;
5077 }
5078
5079 int32_t onContinue()
5080 {
5081 return D_CLOSE;
5082 }
5083
5084 int32_t onEsc() // Unused?? -L
5085 {
5086 return zc_getrawkey(KEY_ESC, true)?D_CLOSE:D_O_K;
5087 }
5088
5089 int32_t onVsync()
5090 {
5091 Throttlefps = !Throttlefps;
5092 zc_set_config(cfg_sect,"throttlefps", (int32_t)Throttlefps);
5093 return D_O_K;
5094 }
5095
5096 int32_t onWinPosSave()
5097 {
5098 SaveWinPos = !SaveWinPos;
5099 zc_set_config(cfg_sect,"save_window_position",(int32_t)SaveWinPos);
5100 return D_O_K;
5101 }
5102 int32_t onIntegerScaling()
5103 {
5104 scaleForceInteger = !scaleForceInteger;
5105 zc_set_config("zeldadx","scaling_force_integer",(int)scaleForceInteger);
5106 return D_O_K;
5107 }
5108 int32_t onStretchGame()
5109 {
5110 stretchGame = !stretchGame;
5111 zc_set_config("zeldadx","stretch_game_area",stretchGame?1:0);
5112 return D_O_K;
5113 }
5114
5115 int32_t onClickToFreeze()
5116 {
5117 ClickToFreeze = !ClickToFreeze;
5118 zc_set_config(cfg_sect,"clicktofreeze", (int32_t)ClickToFreeze);
5119 return D_O_K;
5120 }
5121
5122 int32_t OnSaveZCConfig()
5123 {
5124 if(jwin_alert3(
5125 "Save Configuration",
5126 "Are you sure that you wish to save your present configuration settings?",
5127 "This will overwrite your prior settings!",
5128 NULL,
5129 "&Yes",
5130 "&No",
5131 NULL,
5132 'y',
5133 'n',
5134 0,
5135 get_zc_font(font_lfont)) == 1)
5136 {
5137 save_game_configs();
5138 return D_O_K;
5139 }
5140 else return D_O_K;
5141 }
5142
5143 int32_t OnnClearQuestDir()
5144 {
5145 if(jwin_alert3(
5146 "Clear Current Directory Cache",
5147 "Are you sure that you wish to clear the current cached directory?",
5148 "This will default the current directory to the ROOT for this instance of ZC Player!",
5149 NULL,
5150 "&Yes",
5151 "&No",
5152 NULL,
5153 'y',
5154 'n',
5155 0,
5156 get_zc_font(font_lfont)) == 1)
5157 {
5158 zc_set_config("zeldadx","win_qst_dir","");
5159 flush_config_file();
5160 strcpy(qstdir,"");
5161 #ifdef __EMSCRIPTEN__
5162 em_sync_fs();
5163 #endif
5164 return D_O_K;
5165 }
5166 else return D_O_K;
5167 }
5168
5169
5170 int32_t onConsoleZASM()
5171 {
5172 if ( !zasm_debugger )
5173 {
5174 AlertDialog("WARNING: ZASM Debugger",
5175 "Enabling this will open the ZASM Debugger Console"
5176 "\nThis will likely grind ZC to a halt with lag."
5177 "\nTo make any use of this, it is suggested that you read"
5178 "\nthe documentation for 'void Breakpoint(char[] string);'"
5179 " in 'ZScript_Additions.txt'"
5180 "\nThis is not recommended for normal users,"
5181 " and is only intended for ZC developers,"
5182 "\nor quest developers coding directly in ZASM"
5183 "\nAre you sure that you wish to open the ZASM Debugger?",
5184 [&](bool ret,bool)
5185 {
5186 if(ret)
5187 {
5188 FFCore.ZASMPrint(true);
5189 }
5190 }).show();
5191 return D_O_K;
5192 }
5193 else
5194 {
5195 FFCore.ZASMPrint(false);
5196 return D_O_K;
5197 }
5198 }
5199
5200
5201 int32_t onConsoleZScript()
5202 {
5203 if ( !zscript_debugger )
5204 {
5205 AlertDialog("ZScript Debugger",
5206 "Enabling this will open the ZScript Debugger Console"
5207 "\nThis will display any messages logged by scripts,"
5208 " including script errors."
5209 "\nAre you sure that you wish to open the ZScript Debugger?",
5210 [&](bool ret,bool)
5211 {
5212 if(ret)
5213 {
5214 FFCore.ZScriptConsole(true);
5215 }
5216 }).show();
5217 return D_O_K;
5218 }
5219 else
5220 {
5221 FFCore.ZScriptConsole(false);
5222 return D_O_K;
5223 }
5224 }
5225
5226 int32_t onClrConsoleOnReload()
5227 {
5228 clearConsoleOnReload = !clearConsoleOnReload;
5229 zc_set_config("CONSOLE","clear_console_on_reload",clearConsoleOnReload?1:0);
5230 return D_O_K;
5231 }
5232 int32_t onClrConsoleOnLoad()
5233 {
5234 clearConsoleOnLoad = !clearConsoleOnLoad;
5235 zc_set_config("CONSOLE","clear_console_on_load",clearConsoleOnLoad?1:0);
5236 return D_O_K;
5237 }
5238
5239
5240 int32_t onFrameSkip()
5241 {
5242 FrameSkip = !FrameSkip;
5243 return D_O_K;
5244 }
5245
5246 int32_t onSaveDragResize()
5247 {
5248 SaveDragResize = !SaveDragResize;
5249 zc_set_config(cfg_sect,"save_drag_resize",(int32_t)SaveDragResize);
5250 return D_O_K;
5251 }
5252
5253 int32_t onDragAspect()
5254 {
5255 DragAspect = !DragAspect;
5256 zc_set_config(cfg_sect,"drag_aspect",(int32_t)DragAspect);
5257 return D_O_K;
5258 }
5259
5260 int32_t onTransLayers()
5261 {
5262 TransLayers = !TransLayers;
5263 zc_set_config(cfg_sect,"translayers",(int32_t)TransLayers);
5264 return D_O_K;
5265 }
5266
5267 int32_t onNESquit()
5268 {
5269 NESquit = !NESquit;
5270 zc_set_config(cfg_sect,"fastquit",(int32_t)NESquit);
5271 return D_O_K;
5272 }
5273
5274 int32_t onVolKeys()
5275 {
5276 volkeys = !volkeys;
5277 zc_set_config(sfx_sect,"volkeys",(int32_t)volkeys);
5278 return D_O_K;
5279 }
5280
5281 int32_t onShowFPS()
5282 {
5283 ShowFPS = !ShowFPS;
5284 zc_set_config(cfg_sect,"showfps",(int32_t)ShowFPS);
5285 return D_O_K;
5286 }
5287
5288 1095672952 bool is_Fkey(int32_t k)
5289 {
5290
2/2
✓ Branch 0 taken 111424368 times.
✓ Branch 1 taken 984248584 times.
1095672952 switch(k)
5291 {
5292 case KEY_F1:
5293 case KEY_F2:
5294 case KEY_F3:
5295 case KEY_F4:
5296 case KEY_F5:
5297 case KEY_F6:
5298 case KEY_F7:
5299 case KEY_F8:
5300 case KEY_F9:
5301 case KEY_F10:
5302 case KEY_F11:
5303 case KEY_F12:
5304 111424368 return true;
5305 }
5306
5307 984248584 return false;
5308 1095672952 }
5309
5310 void kb_getkey(DIALOG *d);
5311
5312 //Used by all keyboard key settings dialogues.
5313 void kb_clearjoystick(DIALOG *d)
5314 {
5315 d->flags|=D_SELECTED;
5316
5317 jwin_button_proc(MSG_DRAW,d,0);
5318 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 168, 48, FR_WIN);
5319 // text_mode(vc(11));
5320 textout_centre_ex(gui_bmp, font, "Press any key to clear", gui_bmp->w/2, gui_bmp->h/2 - 8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5321 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, gui_bmp->h/2, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5322
5323 update_hw_screen(true);
5324
5325 clear_keybuf();
5326 int32_t k = next_press_key();
5327 clear_keybuf();
5328
5329 //shnarf
5330 //47=f1
5331 //59=esc
5332 // if(k>0 && k<123 && !((k>46)&&(k<60)))
5333 // *((int32_t*)d->dp3) = k;
5334 if ( k != 59 ) *((int32_t*)d->dp3) = 0;
5335
5336
5337 d->flags&=~D_SELECTED;
5338 }
5339
5340 //Clears key to 0.
5341 //Used by all keyboard key settings dialogues.
5342 void kb_clearkey(DIALOG *d);
5343
5344 int32_t d_j_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5345 {
5346 switch(msg)
5347 {
5348 case MSG_KEY:
5349 case MSG_CLICK:
5350
5351 kb_clearjoystick(d);
5352
5353 while(gui_mouse_b())
5354 {
5355 clear_keybuf();
5356 rest(1);
5357 }
5358
5359 return D_REDRAW;
5360 }
5361
5362 return jwin_button_proc(msg,d,c);
5363 }
5364
5365 int32_t d_kbutton_proc(int32_t msg,DIALOG *d,int32_t c);
5366 //Only used in keyboard settings dialogues to clear keys.
5367 int32_t d_k_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c);
5368
5369 void j_getbtn(DIALOG *d)
5370 {
5371 d->flags|=D_SELECTED;
5372 jwin_button_proc(MSG_DRAW,d,0);
5373 jwin_draw_win(screen, (screen->w-160)/2, (screen->h-48)/2, 160, 48, FR_WIN);
5374 // text_mode(vc(11));
5375 int32_t y = screen->h/2 - 12;
5376 textout_centre_ex(screen, font, "Press a button", screen->w/2, y, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5377 textout_centre_ex(screen, font, "ESC to cancel", screen->w/2, y+8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5378 textout_centre_ex(screen, font, "SPACE to disable", screen->w/2, y+16, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5379
5380 update_hw_screen(true);
5381
5382 int32_t b = next_press_btn();
5383
5384 if(b>=0)
5385 *((int32_t*)d->dp3) = b;
5386
5387 d->flags&=~D_SELECTED;
5388
5389 if (player)
5390 player->joy_on = TRUE;
5391 }
5392
5393 int32_t d_jbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5394 {
5395 switch(msg)
5396 {
5397 case MSG_KEY:
5398 case MSG_CLICK:
5399
5400 j_getbtn(d);
5401
5402 while(gui_mouse_b()) {
5403 rest(1);
5404 clear_keybuf();
5405 }
5406
5407 return D_REDRAW;
5408 }
5409
5410 return jwin_button_proc(msg,d,c);
5411 }
5412
5413 //shnarf
5414 extern const char *key_str[];
5415 std::string get_keystr(int key);
5416
5417 const char *pan_str[4] = { "MONO", " 1/2", " 3/4", "FULL" };
5418 //extern int32_t zcmusic_bufsz;
5419
5420 static char str_a[80],str_b[80],str_s[80],str_m[80],str_l[80],str_r[80],str_p[80],str_ex1[80],str_ex2[80],str_ex3[80],str_ex4[80],
5421 str_leftmod1[80],str_leftmod2[80],str_rightmod1[80],str_rightmod2[80], str_left[80], str_right[80], str_up[80], str_down[80];
5422
5423 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c)
5424 {
5425 //these are here to bypass compiler warnings about unused arguments
5426 c=c;
5427
5428 if(msg==MSG_DRAW)
5429 {
5430 switch(d->w)
5431 {
5432 case 0:
5433 sprintf(str_a,"%03d\n%s",Akey,key_str[Akey]);
5434 sprintf(str_b,"%03d\n%s",Bkey,key_str[Bkey]);
5435 sprintf(str_s,"%03d\n%s",Skey,key_str[Skey]);
5436 sprintf(str_l,"%03d\n%s",Lkey,key_str[Lkey]);
5437 sprintf(str_r,"%03d\n%s",Rkey,key_str[Rkey]);
5438 sprintf(str_p,"%03d\n%s",Pkey,key_str[Pkey]);
5439 sprintf(str_ex1,"%03d\n%s",Exkey1,key_str[Exkey1]);
5440 sprintf(str_ex2,"%03d\n%s",Exkey2,key_str[Exkey2]);
5441 sprintf(str_ex3,"%03d\n%s",Exkey3,key_str[Exkey3]);
5442 sprintf(str_ex4,"%03d\n%s",Exkey4,key_str[Exkey4]);
5443 sprintf(str_up,"%03d\n%s",DUkey,key_str[DUkey]);
5444 sprintf(str_down,"%03d\n%s",DDkey,key_str[DDkey]);
5445 sprintf(str_left,"%03d\n%s",DLkey,key_str[DLkey]);
5446 sprintf(str_right,"%03d\n%s",DRkey,key_str[DRkey]);
5447 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5448 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5449 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5450 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5451 break;
5452
5453 case 1:
5454 sprintf(str_a,"%03d\n%s",Abtn,joybtn_name(Abtn));
5455 sprintf(str_b,"%03d\n%s",Bbtn,joybtn_name(Bbtn));
5456 sprintf(str_s,"%03d\n%s",Sbtn,joybtn_name(Sbtn));
5457 sprintf(str_l,"%03d\n%s",Lbtn,joybtn_name(Lbtn));
5458 sprintf(str_r,"%03d\n%s",Rbtn,joybtn_name(Rbtn));
5459 sprintf(str_m,"%03d\n%s",Mbtn,joybtn_name(Mbtn));
5460 sprintf(str_p,"%03d\n%s",Pbtn,joybtn_name(Pbtn));
5461 sprintf(str_ex1,"%03d\n%s",Exbtn1,joybtn_name(Exbtn1));
5462 sprintf(str_ex2,"%03d\n%s",Exbtn2,joybtn_name(Exbtn2));
5463 sprintf(str_ex3,"%03d\n%s",Exbtn3,joybtn_name(Exbtn3));
5464 sprintf(str_ex4,"%03d\n%s",Exbtn4,joybtn_name(Exbtn4));
5465 sprintf(str_up,"%03d\n%s",DUbtn,joybtn_name(DUbtn));
5466 sprintf(str_down,"%03d\n%s",DDbtn,joybtn_name(DDbtn));
5467 sprintf(str_left,"%03d\n%s",DLbtn,joybtn_name(DLbtn));
5468 sprintf(str_right,"%03d\n%s",DRbtn,joybtn_name(DRbtn));
5469 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5470 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5471 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5472 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5473 break;
5474
5475 case 2:
5476 sprintf(str_a," %3d",midi_volume);
5477 sprintf(str_b," %3d",digi_volume);
5478 sprintf(str_l," %3d",emusic_volume);
5479 sprintf(str_m," %3dKB",zcmusic_bufsz);
5480 sprintf(str_r," %3d",sfx_volume);
5481 strcpy(str_s,pan_str[pan_style]);
5482 sprintf(str_leftmod1,"%3d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5483 sprintf(str_leftmod2,"%3d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5484 sprintf(str_rightmod1,"%3d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5485 sprintf(str_rightmod2,"%3d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5486 break;
5487 }
5488 }
5489
5490 return D_O_K;
5491 }
5492
5493 int32_t set_vol(void *dp3, int32_t d2)
5494 {
5495 switch(((int32_t*)dp3)[0])
5496 {
5497 case 0:
5498 midi_volume = zc_min(d2<<3,255);
5499 break;
5500
5501 case 1:
5502 digi_volume = zc_min(d2<<3,255);
5503 break;
5504
5505 case 2:
5506 emusic_volume = zc_min(d2<<3,255);
5507 break;
5508
5509 case 3:
5510 sfx_volume = zc_min(d2<<3,255);
5511 break;
5512 }
5513
5514 // text_mode(vc(11));
5515 textprintf_right_ex(screen,get_zc_font(font_lfont_l), ((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%3d",zc_min(d2<<3,255));
5516 return D_O_K;
5517 }
5518
5519 int32_t set_pan(void *dp3, int32_t d2)
5520 {
5521 pan_style = vbound(d2,0,3);
5522 // text_mode(vc(11));
5523 textout_right_ex(screen,get_zc_font(font_lfont_l), pan_str[pan_style],((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5524 return D_O_K;
5525 }
5526
5527 int32_t set_buf(void *dp3, int32_t d2)
5528 {
5529 // text_mode(vc(11));
5530 zcmusic_bufsz = d2 + 1;
5531 textprintf_right_ex(screen,get_zc_font(font_lfont_l), ((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%3dKB",zcmusic_bufsz);
5532 return D_O_K;
5533 }
5534
5535 static int32_t gamepad_btn_list[] =
5536 {
5537 6,
5538 7,8,9,10,11,12,13,14,15,16,17,
5539 18,19,20,21,22,23,24,25,26,27,28,
5540 29,30,31,32,33,34,35,36,37,38,39,
5541 -1
5542 };
5543
5544 static int32_t gamepad_dirs_list[] =
5545 {
5546 40,41,42,43,
5547 44,45,46,47,
5548 48,49,50,51,
5549 52,53,54,55,
5550 56,
5551 -1
5552 };
5553
5554 static TABPANEL gamepad_tabs[] =
5555 {
5556 // (text)
5557 { (char *)"Buttons", D_SELECTED, gamepad_btn_list, 0, NULL },
5558 { (char *)"Directions", 0, gamepad_dirs_list, 0, NULL },
5559 { NULL, 0, NULL, 0, NULL }
5560 };
5561
5562 static DIALOG gamepad_dlg[] =
5563 {
5564 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5565 { jwin_win_proc, 8, 24, 304, 256, 0, 0, 0, D_EXIT, 0, 0, (void *) "Gamepad Controls", NULL, NULL },
5566 { jwin_tab_proc, 8+4, 24+23,304-8,256-52,vc(0), vc(15), 0, 0, 0, 0, (void *) gamepad_tabs, NULL, (void *)gamepad_dlg },
5567 { d_stringloader, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5568 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5569 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5570 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5571 // 6
5572 { d_dummy_proc, 14, 61, 294, 192, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5573 // 7
5574 { jwin_ctext_proc, 92, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5575 { jwin_ctext_proc, 92, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5576 { jwin_ctext_proc, 92, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5577 { jwin_ctext_proc, 92, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5578 { jwin_ctext_proc, 92, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5579 { jwin_ctext_proc, 237, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5580 { jwin_ctext_proc, 237, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5581 { jwin_ctext_proc, 237, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5582 { jwin_ctext_proc, 237, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5583 { jwin_ctext_proc, 237, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5584 { jwin_ctext_proc, 92, 244-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_m, NULL, NULL },
5585 // 18
5586 { d_jbutton_proc, 22, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Abtn},
5587 { d_jbutton_proc, 22, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bbtn},
5588 { d_jbutton_proc, 22, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Sbtn},
5589 { d_jbutton_proc, 22, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exbtn1},
5590 { d_jbutton_proc, 22, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exbtn3},
5591 { d_jbutton_proc, 167, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lbtn},
5592 { d_jbutton_proc, 167, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rbtn},
5593 { d_jbutton_proc, 167, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pbtn},
5594 { d_jbutton_proc, 167, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exbtn2},
5595 { d_jbutton_proc, 167, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exbtn4},
5596 { d_jbutton_proc, 22, 242-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Menu", NULL, &Mbtn},
5597 // 29
5598 { d_j_clearbutton_proc, 22+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Abtn},
5599 { d_j_clearbutton_proc, 22+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bbtn},
5600 { d_j_clearbutton_proc, 22+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Sbtn},
5601 { d_j_clearbutton_proc, 22+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn1},
5602 { d_j_clearbutton_proc, 22+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn3},
5603 { d_j_clearbutton_proc, 167+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lbtn},
5604 { d_j_clearbutton_proc, 167+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rbtn},
5605 { d_j_clearbutton_proc, 167+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pbtn},
5606 { d_j_clearbutton_proc, 167+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn2},
5607 { d_j_clearbutton_proc, 167+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn4},
5608 { d_j_clearbutton_proc, 22+91, 242-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Mbtn},
5609 // 40
5610 { jwin_frame_proc, 14, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5611 { jwin_frame_proc, 159, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5612 { jwin_text_proc, 30, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5613 { jwin_text_proc, 175, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5614 // 44
5615 { jwin_text_proc, 92, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5616 { jwin_text_proc, 92, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5617 { jwin_text_proc, 237, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5618 { jwin_text_proc, 237, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5619 // 48
5620 { d_jbutton_proc, 22, 82, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUbtn },
5621 { d_jbutton_proc, 22, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDbtn },
5622 { d_jbutton_proc, 167, 82, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLbtn },
5623 { d_jbutton_proc, 167, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRbtn },
5624 // 52
5625 { d_j_clearbutton_proc, 22+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUbtn},
5626 { d_j_clearbutton_proc, 22+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDbtn},
5627 { d_j_clearbutton_proc, 167+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLbtn},
5628 { d_j_clearbutton_proc, 167+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRbtn},
5629 // 56
5630 { jwin_check_proc, 22, 150, 147, 8, vc(14), vc(1), 0, 0, 1, 0, (void *) "Use Analog Stick/DPad", NULL, NULL },
5631 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5632 };
5633
5634 static int32_t keyboard_keys_list[] =
5635 {
5636 6,7,8,9,10,
5637 11,12,13,14,15,16,17,18,19,20,
5638 21,22,23,24,25,26,27,28,29,30,
5639 31,32,33,34,35,36,37,38,39,40,
5640 -1
5641 };
5642
5643 static int32_t keyboard_dirs_list[] =
5644 {
5645 41,42,43,44,
5646 45,46,47,48,
5647 49,50,51,52,
5648 53,54,55,56,
5649 -1
5650 };
5651
5652 static int32_t keyboard_mods_list[] =
5653 {
5654 57,58,59,60,
5655 61,62,63,64,
5656 65,66,67,68,
5657 69,70,71,72,
5658 -1
5659 };
5660
5661 static TABPANEL keyboard_control_tabs[] =
5662 {
5663 // (text)
5664 { (char *)"Keys", D_SELECTED, keyboard_keys_list, 0, NULL },
5665 { (char *)"Directions", 0, keyboard_dirs_list, 0, NULL },
5666 { (char *)"Cheat Mods", 0, keyboard_mods_list, 0, NULL },
5667 { NULL, 0, NULL, 0, NULL }
5668 };
5669
5670 static DIALOG keyboard_control_dlg[] =
5671 {
5672 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5673 { jwin_win_proc, 8, 39, 304, 240, 0, 0, 0, D_EXIT, 0, 0, (void *) "Keyboard Controls", NULL, NULL },
5674 { jwin_tab_proc, 8+4, 39+23,304-8,240-56,vc(0), vc(15), 0, 0, 0, 0, (void *) keyboard_control_tabs, NULL, (void *)keyboard_control_dlg },
5675 { d_stringloader, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5676 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5677 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5678 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5679 // Keys
5680 // 6
5681 { jwin_frame_proc, 14, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5682 { jwin_frame_proc, 158, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5683 { jwin_frame_proc, 14, 181, 292, 67, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5684 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Standard", NULL, NULL },
5685 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Extended", NULL, NULL },
5686 // 11
5687 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5688 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5689 { jwin_text_proc, 92-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5690 { jwin_text_proc, 92-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5691 { jwin_text_proc, 92-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5692 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5693 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5694 { jwin_text_proc, 237-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5695 { jwin_text_proc, 237-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5696 { jwin_text_proc, 237-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5697 // 21
5698 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Akey},
5699 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bkey},
5700 { d_kbutton_proc, 22, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Skey},
5701 { d_kbutton_proc, 22, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exkey1},
5702 { d_kbutton_proc, 22, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exkey3},
5703 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lkey},
5704 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rkey},
5705 { d_kbutton_proc, 167, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pkey},
5706 { d_kbutton_proc, 167, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exkey2},
5707 { d_kbutton_proc, 167, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exkey4},
5708 // 31
5709 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Akey},
5710 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bkey},
5711 { d_k_clearbutton_proc, 22+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Skey},
5712 { d_k_clearbutton_proc, 22+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey1},
5713 { d_k_clearbutton_proc, 22+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey3},
5714 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lkey},
5715 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rkey},
5716 { d_k_clearbutton_proc, 167+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pkey},
5717 { d_k_clearbutton_proc, 167+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey2},
5718 { d_k_clearbutton_proc, 167+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey4},
5719 // Dirs
5720 // 41
5721 { jwin_frame_proc, 14, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5722 { jwin_frame_proc, 159, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5723 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5724 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5725 // 45
5726 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5727 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5728 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5729 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5730 // 49
5731 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUkey},
5732 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDkey},
5733 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLkey},
5734 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRkey},
5735 // 53
5736 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUkey},
5737 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDkey},
5738 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLkey},
5739 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRkey},
5740 // Mods
5741 // 57
5742 { jwin_frame_proc, 14, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5743 { jwin_frame_proc, 158, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5744 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Left", NULL, NULL },
5745 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Right", NULL, NULL },
5746 // 61
5747 { jwin_text_proc, 92-26, 101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod1, NULL, NULL },
5748 { jwin_text_proc, 92-26, 129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod1, NULL, NULL },
5749 { jwin_text_proc, 237-4-22,101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod2, NULL, NULL },
5750 { jwin_text_proc, 237-4-22,129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod2, NULL, NULL },
5751 // 65
5752 { d_kbutton_proc, 22, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[0]},
5753 { d_kbutton_proc, 22, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[2]},
5754 { d_kbutton_proc, 167, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[1]},
5755 { d_kbutton_proc, 167, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[3]},
5756 // 69
5757 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[0]},
5758 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[2]},
5759 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[1]},
5760 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[3]},
5761 // 73
5762 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5763 };
5764
5765 /*
5766 int32_t midi_dp[3] = {0,147,104};
5767 int32_t digi_dp[3] = {1,147,120};
5768 int32_t pan_dp[3] = {0,147,136};
5769 int32_t buf_dp[3] = {0,147,152};
5770 */
5771 int32_t midi_dp[3] = {0,0,0};
5772 int32_t digi_dp[3] = {1,0,0};
5773 int32_t emus_dp[3] = {2,0,0};
5774 int32_t buf_dp[3] = {0,0,0};
5775 int32_t sfx_dp[3] = {3,0,0};
5776 int32_t pan_dp[3] = {0,0,0};
5777
5778 static DIALOG sound_dlg[] =
5779 {
5780 //(dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5781 114 { jwin_win_proc, 0, 0, 320, 178, 0, 0, 0, D_EXIT, 0, 0, (void *) "Sound Settings", NULL, NULL },
5782 114 { d_stringloader, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5783 114 { jwin_button_proc, 58, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5784 114 { jwin_button_proc, 138, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5785 114 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5786 114 { jwin_frame_proc, 10, 28, 300, 112, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
5787 114 { jwin_rtext_proc, 190, 40, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_a, NULL, NULL },
5788 114 { jwin_rtext_proc, 190, 56, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_b, NULL, NULL },
5789 114 { jwin_rtext_proc, 190, 72, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_l, NULL, NULL },
5790 114 { jwin_rtext_proc, 190, 88, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_m, NULL, NULL },
5791 // 10
5792 114 { jwin_rtext_proc, 190, 104, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_r, NULL, NULL },
5793 114 { jwin_rtext_proc, 190, 120, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_s, NULL, NULL },
5794 114 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5795 114 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5796 114 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5797 114 { jwin_slider_proc, 196, 40, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, midi_dp },
5798 114 { jwin_slider_proc, 196, 56, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, digi_dp },
5799 114 { jwin_slider_proc, 196, 72, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, emus_dp },
5800 114 { jwin_slider_proc, 196, 88, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 127, 0, NULL, (void *) set_buf, buf_dp },
5801 114 { jwin_slider_proc, 196, 104, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, sfx_dp },
5802 //20
5803 114 { jwin_slider_proc, 196, 120, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 3, 0, NULL, (void *) set_pan, pan_dp },
5804 114 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5805 114 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5806 114 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5807 114 { jwin_text_proc, 17, 40, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Master MIDI Volume", NULL, NULL },
5808 114 { jwin_text_proc, 17, 56, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Master Digi Volume", NULL, NULL },
5809 114 { jwin_text_proc, 17, 72, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Enhanced Music Volume", NULL, NULL },
5810 114 { jwin_text_proc, 17, 88, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Enhanced Music Buffer", NULL, NULL },
5811 114 { jwin_text_proc, 17, 104, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Volume", NULL, NULL },
5812 114 { jwin_text_proc, 17, 120, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Pan", NULL, NULL },
5813 //30
5814 114 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5815 114 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5816 114 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5817 114 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5818 };
5819
5820 char zc_builddate[80];
5821 char zc_aboutstr[80];
5822
5823 static DIALOG about_dlg[] =
5824 {
5825 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
5826 { jwin_win_proc, 68, 52, 184, 154, 0, 0, 0, D_EXIT, 0, 0, (void *) "About", NULL, NULL },
5827 { jwin_button_proc, 140, 176, 41, 21, vc(14), 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5828 { jwin_ctext_proc, 160, 84, 0, 8, vc(0), vc(11), 0, 0, 0, 0, zc_aboutstr, NULL, NULL },
5829 { jwin_ctext_proc, 160, 92, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5830 { jwin_ctext_proc, 160, 100, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, zc_builddate, NULL, NULL },
5831 { jwin_text_proc, 88, 124, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Coded by:", NULL, NULL },
5832 { jwin_text_proc, 88, 132, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Phantom Menace", NULL, NULL },
5833 { jwin_text_proc, 88, 144, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Produced by:", NULL, NULL },
5834 { jwin_text_proc, 88, 152, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Armageddon Games", NULL, NULL },
5835 { jwin_frame_proc, 80, 117, 160, 50, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5836 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5837 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5838 };
5839
5840
5841 static DIALOG quest_dlg[] =
5842 {
5843 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
5844 { jwin_win_proc, 68, 25, 184, 190, 0, 0, 0, D_EXIT, 0, 0, (void *) "Quest Info", NULL, NULL },
5845 { jwin_edit_proc, 84, 54, 152, 16, 0, 0, 0, D_READONLY, 100, 0, NULL, NULL, NULL },
5846 { jwin_text_proc, 89, 84, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
5847 { jwin_text_proc, 152, 84, 24, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5848 { jwin_text_proc, 89, 94, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Version:", NULL, NULL },
5849 { jwin_text_proc, 160, 94, 64, 8, vc(7), vc(11), 0, 0, 0, 0, header_version_nul_term, NULL, NULL },
5850 { jwin_text_proc, 89, 104, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "ZQ Version:", NULL, NULL },
5851 { jwin_text_proc, 184, 104, 64, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5852 { jwin_text_proc, 84, 126, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Title:", NULL, NULL },
5853 { jwin_textbox_proc, 84, 136, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.title, NULL, NULL },
5854 { jwin_text_proc, 84, 168, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Author:", NULL, NULL },
5855 { jwin_textbox_proc, 84, 178, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.author, NULL, NULL },
5856 { jwin_frame_proc, 84, 79, 152, 38, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5857 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5858 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5859 };
5860
5861 static DIALOG triforce_dlg[] =
5862 {
5863 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
5864 { jwin_win_proc, 72, 64, 177, 105, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Triforce Pieces", NULL, NULL },
5865 // 1
5866 { jwin_check_proc, 129, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "1", NULL, NULL },
5867 { jwin_check_proc, 129, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "2", NULL, NULL },
5868 { jwin_check_proc, 129, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "3", NULL, NULL },
5869 { jwin_check_proc, 129, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "4", NULL, NULL },
5870 { jwin_check_proc, 172, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "5", NULL, NULL },
5871 { jwin_check_proc, 172, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "6", NULL, NULL },
5872 { jwin_check_proc, 172, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "7", NULL, NULL },
5873 { jwin_check_proc, 172, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "8", NULL, NULL },
5874 // 9
5875 { jwin_button_proc, 90, 144, 61, 21, vc(0), vc(11), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
5876 { jwin_button_proc, 170, 144, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5877 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5878 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5879 };
5880
5881 bool zc_getname(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
5882 {
5883 go();
5884 int32_t ret=0;
5885 ret = zc_getname_nogo(prompt,ext,list,def,usefilename);
5886 comeback();
5887 return ret != 0;
5888 }
5889
5890
5891 bool zc_getname_nogo(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
5892 {
5893 if(def!=modulepath)
5894 strcpy(modulepath,def);
5895
5896 if(!usefilename)
5897 {
5898 int32_t i=(int32_t)strlen(modulepath);
5899
5900 while(i>=0 && modulepath[i]!='\\' && modulepath[i]!='/')
5901 modulepath[i--]=0;
5902 }
5903
5904 // int32_t ret = file_select_ex(prompt,modulepath,ext,255,-1,-1);
5905 int32_t ret=0;
5906 int32_t sel=0;
5907
5908 if(list==NULL)
5909 {
5910 ret = jwin_file_select_ex(prompt,modulepath,ext,2048,-1,-1,get_zc_font(font_lfont));
5911 }
5912 else
5913 {
5914 ret = jwin_file_browse_ex(prompt, modulepath, list, &sel, 2048, -1, -1, get_zc_font(font_lfont));
5915 }
5916
5917 return ret!=0;
5918 }
5919
5920 //The Dialogue that loads a ZMOD Module File
5921 int32_t zc_load_zmod_module_file()
5922 {
5923 if ( Playing )
5924 {
5925 jwin_alert("Error","Cannot change module while playing a quest!",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
5926 return -1;
5927 }
5928 if(!zc_getname("Load Module (.zmod)","zmod",NULL,modulepath,false))
5929 return D_CLOSE;
5930
5931 FILE *tempmodule = fopen(modulepath,"r");
5932
5933 if(tempmodule == NULL)
5934 {
5935 jwin_alert("Error","Cannot open specified file!",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
5936 return -1;
5937 }
5938
5939
5940 //Set the module path:
5941 memset(moduledata.module_name, 0, sizeof(moduledata.module_name));
5942 strcpy(moduledata.module_name, modulepath);
5943 al_trace("New Module Path is: %s \n", moduledata.module_name);
5944 zc_set_config("ZCMODULE","current_module",moduledata.module_name);
5945 zcm.init(true); //Load the module values.
5946 moduledata.refresh_title_screen = 1;
5947 // refresh_select_screen = 1;
5948 return D_O_K;
5949 }
5950
5951 static DIALOG module_info_dlg[] =
5952 {
5953 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
5954
5955
5956 { jwin_win_proc, 0, 0, 200, 200, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "About Current Module", NULL, NULL },
5957 //1
5958 { jwin_text_proc, 10, 20, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Module:", NULL, NULL },
5959 //2
5960 { jwin_text_proc, 50, 20, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5961 { jwin_text_proc, 10, 30, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Author:", NULL, NULL },
5962 //4
5963 { jwin_text_proc, 50, 30, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5964 { jwin_text_proc, 10, 40, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5965 { jwin_text_proc, 10, 50, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Information:", NULL, NULL },
5966 //7
5967
5968 { jwin_text_proc, 10, 60, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5969 { jwin_text_proc, 10, 70, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5970 { jwin_text_proc, 10, 80, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5971 { jwin_text_proc, 10, 90, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5972 { jwin_text_proc, 10, 100, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5973 { jwin_text_proc, 10, 120, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5974 { jwin_text_proc, 10, 130, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5975 { jwin_text_proc, 10, 140, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5976 { jwin_text_proc, 10, 150, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5977
5978 { jwin_button_proc, 40, 160, 50, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5979 { jwin_button_proc, 200-40-50, 160, 50, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5980 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5981 };
5982
5983 void about_zcplayer_module(const char *prompt,int32_t initialval)
5984 {
5985
5986 module_info_dlg[0].dp2 = get_zc_font(font_lfont);
5987 if ( moduledata.moduletitle[0] != 0 )
5988 module_info_dlg[2].dp = (char*)moduledata.moduletitle;
5989
5990 if ( moduledata.moduleauthor[0] != 0 )
5991 module_info_dlg[4].dp = (char*)moduledata.moduleauthor;
5992
5993 if ( moduledata.moduleinfo0[0] != 0 )
5994 module_info_dlg[7].dp = (char*)moduledata.moduleinfo0;
5995 if ( moduledata.moduleinfo1[0] != 0 )
5996 module_info_dlg[8].dp = (char*)moduledata.moduleinfo1;
5997 if ( moduledata.moduleinfo2[0] != 0 )
5998 module_info_dlg[9].dp = (char*)moduledata.moduleinfo2;
5999 if ( moduledata.moduleinfo3[0] != 0 )
6000 module_info_dlg[10].dp = (char*)moduledata.moduleinfo3;
6001 if ( moduledata.moduleinfo4[0] != 0 )
6002 module_info_dlg[11].dp = (char*)moduledata.moduleinfo4;
6003
6004 char module_date[255];
6005 memset(module_date, 0, sizeof(module_date));
6006 sprintf(module_date,"Build Date: %s %s, %d at @ %d:%d %s", dayextension(moduledata.modday).c_str(),
6007 (char*)months[moduledata.modmonth], moduledata.modyear, moduledata.modhour, moduledata.modminute, moduledata.moduletimezone);
6008
6009
6010
6011 char module_vers[255];
6012 memset(module_vers, 0, sizeof(module_vers));
6013 sprintf(module_vers, "Version: %d.%d.%d.%d", moduledata.modver_1, moduledata.modver_2, moduledata.modver_3, moduledata.modver_4);
6014
6015
6016 //sprintf(tilecount,"%d",1);
6017
6018 char module_build[255];
6019 memset(module_build, 0, sizeof(module_build));
6020 if ( moduledata.modbeta )
6021 sprintf(module_build,"Module Build: %d, %s: %d", moduledata.modbuild, (moduledata.modbeta<0) ? "Alpha" : "Beta", moduledata.modbeta );
6022 else
6023 sprintf(module_build,"Module Build: %d", moduledata.modbuild);
6024
6025 module_info_dlg[12].dp = (char*)module_date;
6026 module_info_dlg[13].dp = (char*)module_vers;
6027 module_info_dlg[14].dp = (char*)module_build;
6028
6029 large_dialog(module_info_dlg);
6030
6031 int32_t ret = zc_popup_dialog(module_info_dlg,-1);
6032 jwin_center_dialog(module_info_dlg);
6033
6034
6035 }
6036
6037 int32_t onAbout_ZCP_Module()
6038 {
6039 about_zcplayer_module("About Module (.zmod)", 0);
6040 return D_O_K;
6041 }
6042
6043 //New Modules Menu for 2.55+
6044 static MENU zcmodule_menu[] =
6045 {
6046 { (char *)"&Load Module...", zc_load_zmod_module_file, NULL, 0, NULL },
6047 { (char *)"&About Module", onAbout_ZCP_Module, NULL, 0, NULL },
6048
6049 { NULL, NULL, NULL, 0, NULL }
6050 };
6051
6052 int32_t onToggleRecordingNewSaves()
6053 {
6054 if (zc_get_config("zeldadx", "replay_new_saves", false))
6055 {
6056 zc_set_config("zeldadx", "replay_new_saves", false);
6057 }
6058 else
6059 {
6060 zc_set_config("zeldadx", "replay_new_saves", true);
6061 jwin_alert("Recording", "Newly created saves will be recorded and written to a replay file.",
6062 NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6063 }
6064 return D_O_K;
6065 }
6066
6067 int32_t onToggleSnapshotAllFrames()
6068 {
6069 replay_set_snapshot_all_frames(!replay_is_snapshot_all_frames());
6070 return D_O_K;
6071 }
6072
6073 int32_t onStopReplayOrRecord()
6074 {
6075 if (replay_is_replaying())
6076 {
6077 replay_quit();
6078 }
6079 else if (replay_get_mode() == ReplayMode::Record)
6080 {
6081 if (!replay_get_meta_bool("test_mode"))
6082 {
6083 jwin_alert("Recording", "You cannot stop recording a save file.",
6084 NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6085 return D_CLOSE;
6086 }
6087
6088 if (jwin_alert("Stop Recording",
6089 "Save replay to disk and stop recording?",
6090 "This will stop the recording.",
6091 NULL,
6092 "Yes","No",13,27,get_zc_font(font_lfont)) != 1)
6093 return D_CLOSE;
6094
6095 replay_save();
6096 replay_stop();
6097 }
6098 return D_O_K;
6099 }
6100
6101 static int32_t handle_on_load_replay(ReplayMode mode)
6102 {
6103 if (Playing)
6104 {
6105 if (jwin_alert("Replay - Warning!",
6106 "Loading a replay will exit the current game.",
6107 "All unsaved progress will be lost.",
6108 "Do you wish to continue?",
6109 "Yes","No",13,27,get_zc_font(font_lfont)) != 1)
6110 return D_CLOSE;
6111 }
6112
6113 std::string mode_string = replay_mode_to_string(mode);
6114 mode_string[0] = std::toupper(mode_string[0]);
6115
6116 std::string line_1 = "Select a replay file to play back.";
6117 std::string line_2 = "You won't be able to save, and it won't effect existing saves.";
6118 std::string line_3 = "You can stop the replay and take over manually any time.";
6119 if (mode == ReplayMode::Update)
6120 {
6121 line_1 = "Select a replay file to update.";
6122 line_2 = "WARNING: be sure to back up the zplay file";
6123 line_3 = "and verify that the updated replay works as expected!";
6124 }
6125
6126 if (jwin_alert(mode_string.c_str(),
6127 line_1.c_str(),
6128 line_2.c_str(),
6129 line_3.c_str(),
6130 "OK","Nevermind",13,27,get_zc_font(font_lfont)) == 1)
6131 {
6132 char replay_path[2048];
6133 strcpy(replay_path, "replays/");
6134 if (jwin_file_select_ex(
6135 fmt::format("Load Replay ({})", REPLAY_EXTENSION).c_str(),
6136 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, get_zc_font(font_lfont)) == 0)
6137 return D_CLOSE;
6138
6139 replay_quit();
6140 load_replay_file_deferred(mode, replay_path);
6141 Quit = qRESET;
6142 return D_CLOSE;
6143 }
6144 return D_O_K;
6145 }
6146
6147 int32_t onLoadReplay()
6148 {
6149 return handle_on_load_replay(ReplayMode::Replay);
6150 }
6151
6152 int32_t onLoadReplayAssert()
6153 {
6154 return handle_on_load_replay(ReplayMode::Assert);
6155 }
6156
6157 int32_t onLoadReplayUpdate()
6158 {
6159 return handle_on_load_replay(ReplayMode::Update);
6160 }
6161
6162 int32_t onSaveReplay()
6163 {
6164 if (replay_get_mode() == ReplayMode::Record)
6165 {
6166 if (!replay_get_meta_bool("test_mode"))
6167 {
6168 if (jwin_alert("Save Replay",
6169 "This will save a copy of the replay up to this point.",
6170 "The official replay file will be untouched.",
6171 "Do you wish to continue?",
6172 "Yes","No",13,27,get_zc_font(font_lfont)) != 1)
6173 return D_CLOSE;
6174
6175 char replay_path[2048];
6176 strcpy(replay_path, replay_get_replay_path().string().c_str());
6177 if (jwin_file_select_ex(
6178 fmt::format("Save Replay ({})", REPLAY_EXTENSION).c_str(),
6179 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, get_zc_font(font_lfont)) == 0)
6180 return D_CLOSE;
6181
6182 if (fileexists(replay_path))
6183 {
6184 jwin_alert("Save Replay", "You cannot overwrite an existing file.",
6185 NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6186 return D_CLOSE;
6187 }
6188
6189 replay_save(replay_path);
6190 }
6191 else
6192 {
6193 replay_save();
6194 }
6195 }
6196 return D_O_K;
6197 }
6198
6199 static MENU replay_menu[] =
6200 {
6201 { (char *)"Record new saves", onToggleRecordingNewSaves, NULL, 0, NULL },
6202 { (char *)"Stop replay", onStopReplayOrRecord, NULL, 0, NULL },
6203 { (char *)"Load replay", onLoadReplay, NULL, 0, NULL },
6204 { (char *)"Load replay (assert)", onLoadReplayAssert, NULL, 0, NULL },
6205 { (char *)"Load replay (update)", onLoadReplayUpdate, NULL, 0, NULL },
6206 { (char *)"Save replay", onSaveReplay, NULL, 0, NULL },
6207 { (char *)"Enable snapshot all frames", onToggleSnapshotAllFrames,NULL, 0, NULL },
6208
6209 { NULL, NULL, NULL, 0, NULL }
6210 };
6211
6212 static DIALOG credits_dlg[] =
6213 {
6214 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6215 { jwin_win_proc, 40, 38, 241, 173, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "ZQuest Classic Credits", NULL, NULL },
6216 { jwin_frame_proc, 47, 65, 227, 115, vc(15), vc(1), 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
6217 { d_bitmap_proc, 49, 67, 222, 110, vc(15), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
6218 { jwin_button_proc, 140, 184, 41, 21, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6219 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6220 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6221 };
6222
6223 114 static ListData dmap_list(dmaplist, &font);
6224
6225 static DIALOG goto_dlg[] =
6226 {
6227 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6228 { jwin_win_proc, 48, 25, 205, 100, 0, 0, 0, D_EXIT, 0, 0, (void *) "Goto Location", NULL, NULL },
6229 { jwin_button_proc, 90, 176-78, 61, 21, vc(14), 0, 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6230 { jwin_button_proc, 170, 176-78, 61, 21, vc(14), 0, 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6231 { jwin_text_proc, 55, 129-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "DMap:", NULL, NULL },
6232 { jwin_droplist_proc, 88, 126-75, 160, 16, 0, 0, 0, 0, 0, 0, (void *) &dmap_list, NULL, NULL },
6233 { jwin_text_proc, 55, 149-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Screen:", NULL, NULL },
6234 { jwin_edit_proc, 132, 146-75, 91, 16, 0, 0, 0, 0, 2, 0, NULL, NULL, NULL },
6235 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6236 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6237 };
6238
6239 int32_t onGoTo()
6240 {
6241 bool music = false;
6242 music = music;
6243 sprintf(cheat_goto_screen_str,"%X",cheat_goto_screen);
6244
6245 goto_dlg[0].dp2=get_zc_font(font_lfont);
6246 goto_dlg[4].d2=cheat_goto_dmap;
6247 goto_dlg[6].dp=cheat_goto_screen_str;
6248
6249 clear_keybuf();
6250
6251 large_dialog(goto_dlg);
6252
6253 if(zc_popup_dialog(goto_dlg,4)==1)
6254 {
6255 // dmap, screen
6256 cheats_enqueue(Cheat::GoTo, goto_dlg[4].d2, zc_min(zc_xtoi(cheat_goto_screen_str),0x7F));
6257 };
6258
6259 return D_O_K;
6260 }
6261
6262 int32_t onGoToComplete()
6263 {
6264 if(!Playing)
6265 {
6266 return D_O_K;
6267 }
6268
6269 enter_sys_pal();
6270 music_pause();
6271 pause_all_sfx();
6272 onGoTo();
6273 eat_buttons();
6274
6275 zc_readrawkey(KEY_ESC);
6276
6277 exit_sys_pal();
6278 music_resume();
6279 resume_all_sfx();
6280 return D_O_K;
6281 }
6282
6283 int32_t onCredits()
6284 {
6285 go();
6286
6287 BITMAP *win = create_bitmap_ex(8,222,110);
6288
6289 if(!win)
6290 return D_O_K;
6291
6292 int32_t c=0;
6293 int32_t l=0;
6294 int32_t ol=-1;
6295 RLE_SPRITE *rle = (RLE_SPRITE*)(datafile[RLE_CREDITS].dat);
6296 RGB *pal = (RGB*)(datafile[PAL_CREDITS].dat);
6297 PALETTE tmppal;
6298
6299 rti_gui.transparency_index = 1;
6300
6301 clear_to_color(win, rti_gui.transparency_index);
6302 draw_rle_sprite(win,rle,0,0);
6303 credits_dlg[0].dp2=get_zc_font(font_lfont);
6304 credits_dlg[1].fg = jwin_pal[jcDISABLED_FG];
6305 credits_dlg[2].dp = win;
6306
6307 zc_set_palette_range(black_palette,0,127,false);
6308
6309 DIALOG_PLAYER *p = init_dialog(credits_dlg,3);
6310
6311 BITMAP* old_screen = screen;
6312 BITMAP* gui_bmp = zc_get_gui_bmp();
6313 ASSERT(gui_bmp);
6314 clear_to_color(gui_bmp, rti_gui.transparency_index);
6315 screen = gui_bmp;
6316
6317 while(update_dialog(p))
6318 {
6319 throttleFPS();
6320 ++c;
6321 l = zc_max((c>>1)-30,0);
6322
6323 if(l > rle->h)
6324 l = c = 0;
6325
6326 if(l > rle->h - 112)
6327 l = rle->h - 112;
6328
6329 clear_bitmap(win);
6330 draw_rle_sprite(win,rle,0,0-l);
6331
6332 if(c<=64)
6333 fade_interpolate(black_palette,pal,tmppal,c,0,127);
6334
6335 zc_set_palette_range(tmppal,0,127,false);
6336
6337 if(l!=ol)
6338 {
6339 d_bitmap_proc(MSG_DRAW,credits_dlg+2,0);
6340 SCRFIX();
6341 ol=l;
6342 }
6343
6344 update_hw_screen();
6345 }
6346
6347 screen = old_screen;
6348 system_pal(true);
6349 sys_mouse();
6350
6351 shutdown_dialog(p);
6352 destroy_bitmap(win);
6353 //comeback();
6354
6355 rti_gui.transparency_index = 0;
6356 clear_to_color(gui_bmp, rti_gui.transparency_index);
6357
6358 return D_O_K;
6359 }
6360
6361 const char *midilist(int32_t index, int32_t *list_size)
6362 {
6363 if(index<0)
6364 {
6365 *list_size=0;
6366
6367 for(int32_t i=0; i<MAXMIDIS; i++)
6368 if(tunes[i].data)
6369 ++(*list_size);
6370
6371 return NULL;
6372 }
6373
6374 int32_t i=0,m=0;
6375
6376 while(m<=index && i<=MAXMIDIS)
6377 {
6378 if(tunes[i].data)
6379 ++m;
6380
6381 ++i;
6382 }
6383
6384 --i;
6385
6386 if(i==MAXMIDIS && m<index)
6387 return "(null)";
6388
6389 return tunes[i].title;
6390 }
6391
6392 /* ------- MIDI info stuff -------- */
6393
6394 char *text;
6395 midi_info *zmi;
6396 bool dialog_running;
6397 bool listening;
6398
6399 void get_info(int32_t index);
6400
6401 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c)
6402 {
6403 int32_t d2 = d->d2;
6404 int32_t ret = jwin_droplist_proc(msg,d,c);
6405
6406 if(d2!=d->d2)
6407 {
6408 get_info(d->d2);
6409 }
6410
6411 return ret;
6412 }
6413
6414 int32_t d_listen_proc(int32_t msg,DIALOG *d,int32_t c)
6415 {
6416 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6417
6418 int32_t ret = jwin_button_proc(msg,d,c);
6419
6420 if(ret == D_CLOSE)
6421 {
6422 // get current midi index
6423 int32_t index = (d+(d->d1))->d2;
6424 int32_t i=0, m=0;
6425
6426 while(m<=index && i<=MAXMIDIS)
6427 {
6428 if(tunes[i].data)
6429 ++m;
6430
6431 ++i;
6432 }
6433
6434 --i;
6435 jukebox(i);
6436 listening = true;
6437 ret = D_O_K;
6438 }
6439
6440 return ret;
6441 }
6442
6443 int32_t d_savemidi_proc(int32_t msg,DIALOG *d,int32_t c)
6444 {
6445 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6446
6447 int32_t ret = jwin_button_proc(msg,d,c);
6448
6449 if(ret == D_CLOSE)
6450 {
6451 // get current midi index
6452 int32_t index = (d+(d->d1))->d2;
6453 int32_t i=0, m=0;
6454
6455 while(m<=index && i<=MAXMIDIS)
6456 {
6457 if(tunes[i].data)
6458 ++m;
6459
6460 ++i;
6461 }
6462
6463 --i;
6464
6465 // get file name
6466
6467 int32_t sel=0;
6468 //struct ffblk f;
6469 char title[40] = "Save MIDI: ";
6470 char fname[2048];
6471 memset(fname,0,2048);
6472 static EXT_LIST list[] =
6473 {
6474 { (char *)"MIDI files (*.mid)", (char *)"mid" },
6475 { (char *)"HTML files (*.html, *.html)", (char *)"htm html" },
6476 { NULL, NULL }
6477 };
6478
6479 strcpy(title+11, tunes[i].title);
6480 title[39] = '\0';
6481
6482 if(jwin_file_browse_ex(title, fname, list, &sel, 2048, -1, -1, get_zc_font(font_lfont))==0)
6483 goto done;
6484
6485 if(exists(fname))
6486 {
6487 if(jwin_alert(title, fname, "already exists.", "Overwrite it?", "&Yes","&No",'y','n',get_zc_font(font_lfont))==2)
6488 goto done;
6489 }
6490
6491 // save midi i
6492
6493 if(save_midi(fname, (MIDI*)tunes[i].data) != 0)
6494 jwin_alert(title, "Error saving MIDI to", fname, NULL, "Darn", NULL,13,27,get_zc_font(font_lfont));
6495
6496 done:
6497 chop_path(fname);
6498 ret = D_REDRAW;
6499 }
6500
6501 return ret;
6502 }
6503
6504 114 static ListData midi_list(midilist, &font);
6505
6506 static DIALOG midi_dlg[] =
6507 {
6508 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6509 { jwin_win_proc, 8, 28, 304, 184, 0, 0, 0, D_EXIT, 0, 0, (void *) "MIDI Info", NULL, NULL },
6510 { jwin_text_proc, 32, 60, 40, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Tune:", NULL, NULL },
6511 { d_midilist_proc, 80, 56, 192, 16, 0, 0, 0, 0, 0, 0, (void *) &midi_list, NULL, NULL },
6512 { jwin_textbox_proc, 15, 80, 290, 96, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6513 { d_listen_proc, 24, 183, 72, 21, 0, 0, 'l', D_EXIT, -2, 0, (void *) "&Listen", NULL, NULL },
6514 { d_savemidi_proc, 108, 183, 72, 21, 0, 0, 's', D_EXIT, -3, 0, (void *) "&Save", NULL, NULL },
6515 { jwin_button_proc, 236, 183, 61, 21, 0, 0, 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6516 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6517 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6518 };
6519
6520 void get_info(int32_t index)
6521 {
6522 int32_t i=0, m=0;
6523
6524 while(m<=index && i<=MAXMIDIS)
6525 {
6526 if(tunes[i].data)
6527 ++m;
6528
6529 ++i;
6530 }
6531
6532 --i;
6533
6534 if(i==MAXMIDIS && m<index)
6535 strcpy(text,"(null)");
6536 else
6537 {
6538 get_midi_info((MIDI*)tunes[i].data,zmi);
6539 get_midi_text((MIDI*)tunes[i].data,zmi,text);
6540 }
6541
6542 midi_dlg[0].dp2=get_zc_font(font_lfont);
6543 midi_dlg[3].dp = text;
6544 midi_dlg[3].d1 = midi_dlg[3].d2 = 0;
6545 midi_dlg[5].flags = (tunes[i].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6546
6547 if(dialog_running)
6548 {
6549 jwin_textbox_proc(MSG_DRAW,midi_dlg+3,0);
6550 d_savemidi_proc(MSG_DRAW,midi_dlg+5,0);
6551 }
6552 }
6553
6554 int32_t onMIDICredits()
6555 {
6556 text = (char*)malloc(4096);
6557 zmi = (midi_info*)malloc(sizeof(midi_info));
6558
6559 if(!text || !zmi)
6560 {
6561 jwin_alert(NULL,"Not enough memory",NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6562 return D_O_K;
6563 }
6564
6565 bool do_pause_midi = midi_pos >= 0 && currmidi;
6566 auto restore_midi = currmidi;
6567 if(do_pause_midi)
6568 {
6569 paused_midi_pos = midi_pos;
6570 stop_midi();
6571 midi_suspended = midissuspHALTED;
6572 }
6573
6574 midi_dlg[0].dp2=get_zc_font(font_lfont);
6575 midi_dlg[2].d1 = 0;
6576 midi_dlg[2].d2 = 0;
6577 midi_dlg[4].flags = D_EXIT;
6578 midi_dlg[5].flags = (tunes[midi_dlg[2].d1].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6579
6580 listening = false;
6581 dialog_running=false;
6582 get_info(0);
6583
6584 dialog_running=true;
6585
6586 large_dialog(midi_dlg);
6587
6588 zc_popup_dialog(midi_dlg,0);
6589 dialog_running=false;
6590
6591 if(listening)
6592 music_stop();
6593
6594 if(do_pause_midi)
6595 {
6596 // TODO: this probably doesn't resume midis nicely when scrolling (or in some other inner-gameloop).
6597 midi_suspended = midissuspRESUME;
6598 currmidi = restore_midi;
6599 midi_pos = paused_midi_pos;
6600 }
6601
6602 if(text) free(text);
6603 if(zmi) free(zmi);
6604 return D_O_K;
6605 }
6606
6607 int32_t onAbout()
6608 {
6609 char buf1[80]={0};
6610 std::ostringstream oss;
6611 sprintf(buf1,"%s (%s), Version: %s", ZC_PLAYER_NAME,PROJECT_NAME,ZC_PLAYER_V);
6612 oss << buf1 << '\n';
6613 sprintf(buf1, "%s, Build %d", ALPHA_VER_STR, VERSION_BUILD);
6614 oss << buf1 << '\n';
6615 sprintf(buf1,"Build Date: %s %s, %d at @ %s %s", dayextension(BUILDTM_DAY).c_str(), (char*)months[BUILDTM_MONTH], BUILDTM_YEAR, __TIME__, __TIMEZONE__);
6616 oss << buf1 << '\n';
6617 sprintf(buf1, "Built By: %s", DEV_SIGNOFF);
6618 oss << buf1 << '\n';
6619 sprintf(buf1, "Tag: %s", getReleaseTag());
6620 oss << buf1 << '\n';
6621
6622 InfoDialog("About ZC", oss.str()).show();
6623 return D_O_K;
6624 }
6625
6626 int32_t onQuest()
6627 {
6628 char fname[100];
6629 strcpy(fname, get_filename(qstpath));
6630 quest_dlg[0].dp2=get_zc_font(font_lfont);
6631 quest_dlg[1].dp = fname;
6632
6633 if(QHeader.quest_number==0)
6634 sprintf(str_a,"Custom");
6635 else
6636 sprintf(str_a,"%d",QHeader.quest_number);
6637
6638 sprintf(str_s,"%s",VerStr(QHeader.zelda_version));
6639
6640 quest_dlg[11].d1 = quest_dlg[9].d1 = 0;
6641 quest_dlg[11].d2 = quest_dlg[9].d2 = 0;
6642
6643 large_dialog(quest_dlg);
6644
6645 zc_popup_dialog(quest_dlg, 0);
6646 return D_O_K;
6647 }
6648
6649 void call_vidmode_dlg();
6650 int32_t onVidMode()
6651 {
6652 call_vidmode_dlg();
6653 return D_O_K;
6654 }
6655
6656 #define addToHash(c,b,h) if(h->find(c ## key) == h->end()) \
6657 {(*h)[c ## key]=true;} else { if ( c ## key != 0 ) b = false;}
6658 //Added an extra statement, so that if the key is cleared to 0, the cleared
6659 //keybinding status need not be unique. -Z ( 1st April, 2019 )
6660
6661 void load_ukeys(int32_t* arr)
6662 {
6663 arr[ukey_a] = Akey;
6664 arr[ukey_b] = Bkey;
6665 arr[ukey_s] = Skey;
6666 arr[ukey_l] = Lkey;
6667 arr[ukey_r] = Rkey;
6668 arr[ukey_p] = Pkey;
6669 arr[ukey_ex1] = Exkey1;
6670 arr[ukey_ex2] = Exkey2;
6671 arr[ukey_ex3] = Exkey3;
6672 arr[ukey_ex4] = Exkey4;
6673 arr[ukey_du] = DUkey;
6674 arr[ukey_dd] = DDkey;
6675 arr[ukey_dl] = DLkey;
6676 arr[ukey_dr] = DRkey;
6677 arr[ukey_mod1a] = cheat_modifier_keys[0];
6678 arr[ukey_mod1b] = cheat_modifier_keys[1];
6679 arr[ukey_mod2a] = cheat_modifier_keys[2];
6680 arr[ukey_mod2b] = cheat_modifier_keys[3];
6681 };
6682
6683 static const char* ukey_names[] = {
6684 "A", "B", "Start", "L", "R", "Map",
6685 "Ex1", "Ex2", "Ex3", "Ex4", "Up", "Down",
6686 "Left", "Right", "Cheat Mod L1", "Cheat Mod L2",
6687 "Cheat Mod R1", "Cheat Mod R2",
6688 };
6689 std::string get_ukey_name(int32_t k)
6690 {
6691 if (k < num_ukey) return ukey_names[k];
6692 return "";
6693 }
6694
6695 int32_t onKeyboard()
6696 {
6697 int32_t a = Akey;
6698 int32_t b = Bkey;
6699 int32_t s = Skey;
6700 int32_t l = Lkey;
6701 int32_t r = Rkey;
6702 int32_t p = Pkey;
6703 int32_t ex1 = Exkey1;
6704 int32_t ex2 = Exkey2;
6705 int32_t ex3 = Exkey3;
6706 int32_t ex4 = Exkey4;
6707 int32_t du = DUkey;
6708 int32_t dd = DDkey;
6709 int32_t dl = DLkey;
6710 int32_t dr = DRkey;
6711 int32_t mod1a = cheat_modifier_keys[0];
6712 int32_t mod1b = cheat_modifier_keys[1];
6713 int32_t mod2a = cheat_modifier_keys[2];
6714 int32_t mod2b = cheat_modifier_keys[3];
6715 bool done=false;
6716 int32_t ret;
6717
6718 keyboard_control_dlg[0].dp2=get_zc_font(font_lfont);
6719
6720 large_dialog(keyboard_control_dlg);
6721
6722 while(!done)
6723 {
6724 ret = zc_popup_dialog(keyboard_control_dlg,3);
6725
6726 if(ret==3) // OK
6727 {
6728 int32_t ukeys[num_ukey];
6729 load_ukeys(ukeys);
6730 std::vector<std::string> uniqueError;
6731 for(int32_t q = 0; q < num_ukey; ++q)
6732 {
6733 for(int32_t p = q+1; p < num_ukey; ++p)
6734 {
6735 if(ukeys[q] == ukeys[p] && ukeys[q] != 0)
6736 {
6737 char buf[64];
6738 sprintf(buf, "'%s' conflicts with '%s'", get_ukey_name(q).c_str(), get_ukey_name(p).c_str());
6739 std::string str(buf);
6740 uniqueError.push_back(str);
6741 }
6742 }
6743 }
6744 if(uniqueError.size() == 0)
6745 {
6746 done = true;
6747 save_control_configs(true);
6748 }
6749 else
6750 {
6751 box_start(1, "Duplicate Keys", get_zc_font(font_lfont), get_zc_font(font_sfont), false, keyboard_control_dlg[0].w,keyboard_control_dlg[0].h, 2);
6752 box_out("Cannot have duplicate keybinds!"); box_eol();
6753 for(std::vector<std::string>::iterator it = uniqueError.begin();
6754 it != uniqueError.end(); ++it)
6755 {
6756 box_out((*it).c_str()); box_eol();
6757 }
6758 box_end(true);
6759 }
6760 }
6761 else // Cancel
6762 {
6763 Akey = a;
6764 Bkey = b;
6765 Skey = s;
6766 Lkey = l;
6767 Rkey = r;
6768 Pkey = p;
6769 Exkey1 = ex1;
6770 Exkey2 = ex2;
6771 Exkey3 = ex3;
6772 Exkey4 = ex4;
6773 DUkey = du;
6774 DDkey = dd;
6775 DLkey = dl;
6776 DRkey = dr;
6777 cheat_modifier_keys[0] = mod1a;
6778 cheat_modifier_keys[1] = mod1b;
6779 cheat_modifier_keys[2] = mod2a;
6780 cheat_modifier_keys[3] = mod2b;
6781
6782 done=true;
6783 }
6784
6785 rest(1);
6786 }
6787
6788 return D_O_K;
6789 }
6790
6791 int32_t onGamepad()
6792 {
6793 int32_t a = Abtn;
6794 int32_t b = Bbtn;
6795 int32_t s = Sbtn;
6796 int32_t l = Lbtn;
6797 int32_t r = Rbtn;
6798 int32_t m = Mbtn;
6799 int32_t p = Pbtn;
6800 int32_t ex1 = Exbtn1;
6801 int32_t ex2 = Exbtn2;
6802 int32_t ex3 = Exbtn3;
6803 int32_t ex4 = Exbtn4;
6804 int32_t up = DUbtn;
6805 int32_t down = DDbtn;
6806 int32_t left = DLbtn;
6807 int32_t right = DRbtn;
6808
6809 gamepad_dlg[0].dp2=get_zc_font(font_lfont);
6810 if(analog_movement)
6811 gamepad_dlg[56].flags|=D_SELECTED;
6812 else
6813 gamepad_dlg[56].flags&=~D_SELECTED;
6814
6815 large_dialog(gamepad_dlg);
6816
6817 int32_t ret = zc_popup_dialog(gamepad_dlg,4);
6818
6819 if(ret == 4) //OK
6820 {
6821 analog_movement = gamepad_dlg[56].flags&D_SELECTED;
6822 save_control_configs(false);
6823 }
6824 else //Cancel
6825 {
6826 Abtn = a;
6827 Bbtn = b;
6828 Sbtn = s;
6829 Lbtn = l;
6830 Rbtn = r;
6831 Mbtn = m;
6832 Pbtn = p;
6833 Exbtn1 = ex1;
6834 Exbtn2 = ex2;
6835 Exbtn3 = ex3;
6836 Exbtn4 = ex4;
6837 DUbtn = up;
6838 DDbtn = down;
6839 DLbtn = left;
6840 DRbtn = right;
6841 }
6842
6843 return D_O_K;
6844 }
6845
6846 int32_t onCheatKeys()
6847 {
6848 int32_t oldcheats[Cheat::Last][2];
6849 memcpy(oldcheats, cheatkeys, sizeof(cheatkeys));
6850
6851 bool done=false;
6852
6853 while(!done)
6854 {
6855 bool confirm = false;
6856 CheatKeysDialog(&confirm).show();
6857 if(confirm) // OK
6858 {
6859 std::vector<std::string> uniqueError;
6860 char buf[512];
6861 for(size_t q = 1; q < Cheat::Last; ++q)
6862 {
6863 if(cheatkeys[q][1] && !cheatkeys[q][0])
6864 {
6865 cheatkeys[q][0] = cheatkeys[q][1];
6866 cheatkeys[q][1] = 0;
6867 }
6868 }
6869 for(size_t q = 1; q < Cheat::Last; ++q)
6870 {
6871 if(!bindable_cheat((Cheat)q)) continue;
6872 for(size_t p = q+1; p < Cheat::Last; ++p)
6873 {
6874 if(!bindable_cheat((Cheat)p)) continue;
6875 for(size_t q2 = 0; q2 <= 1; ++q2)
6876 for(size_t p2 = 0; p2 <= 1; ++p2)
6877 {
6878 if(cheatkeys[q][q2] == cheatkeys[p][p2] && cheatkeys[q][q2] != 0)
6879 {
6880 uniqueError.push_back(fmt::format("'{}' ({}) conflicts with '{}' ({}) - both '{}'",
6881 cheat_to_string((Cheat)q), q2?"Alt":"Main",
6882 cheat_to_string((Cheat)p), p2?"Alt":"Main",
6883 get_keystr(cheatkeys[q][q2])));
6884 }
6885 }
6886 }
6887 }
6888 if(uniqueError.size() == 0)
6889 {
6890 done = true;
6891 save_cheatkeys();
6892 }
6893 else
6894 {
6895 box_start(1, "Duplicate Keys", get_zc_font(font_lfont), get_zc_font(font_sfont), false, 500,400, 2);
6896 box_out("Cannot have duplicate keybinds!"); box_eol();
6897 for(std::vector<std::string>::iterator it = uniqueError.begin();
6898 it != uniqueError.end(); ++it)
6899 {
6900 box_out((*it).c_str()); box_eol();
6901 }
6902 box_end(true);
6903 }
6904 }
6905 else // Cancel
6906 {
6907 memcpy(cheatkeys, oldcheats, sizeof(cheatkeys));
6908 done=true;
6909 }
6910 rest(1);
6911 }
6912
6913 return D_O_K;
6914 }
6915
6916 int32_t onSound()
6917 {
6918 if (get_qr(qr_OLD_SCRIPT_VOLUME))
6919 {
6920 if (FFCore.coreflags & FFCORE_SCRIPTED_MIDI_VOLUME)
6921 {
6922 master_volume(-1, ((int32_t)FFCore.usr_midi_volume));
6923 }
6924 if (FFCore.coreflags & FFCORE_SCRIPTED_DIGI_VOLUME)
6925 {
6926 master_volume((int32_t)(FFCore.usr_digi_volume), 1);
6927 }
6928 if (FFCore.coreflags & FFCORE_SCRIPTED_MUSIC_VOLUME)
6929 {
6930 emusic_volume = (int32_t)FFCore.usr_music_volume;
6931 }
6932 if (FFCore.coreflags & FFCORE_SCRIPTED_SFX_VOLUME)
6933 {
6934 sfx_volume = (int32_t)FFCore.usr_sfx_volume;
6935 }
6936 }
6937 if ( FFCore.coreflags&FFCORE_SCRIPTED_PANSTYLE )
6938 {
6939 pan_style = (int32_t)FFCore.usr_panstyle;
6940 }
6941
6942 int32_t m = midi_volume;
6943 int32_t d = digi_volume;
6944 int32_t e = emusic_volume;
6945 int32_t b = zcmusic_bufsz;
6946 int32_t s = sfx_volume;
6947 int32_t p = pan_style;
6948 pan_style = vbound(pan_style,0,3);
6949
6950 sound_dlg[0].dp2=get_zc_font(font_lfont);
6951
6952 large_dialog(sound_dlg);
6953
6954 midi_dp[1] = sound_dlg[6].x;
6955 midi_dp[2] = sound_dlg[6].y;
6956 digi_dp[1] = sound_dlg[7].x;
6957 digi_dp[2] = sound_dlg[7].y;
6958 emus_dp[1] = sound_dlg[8].x;
6959 emus_dp[2] = sound_dlg[8].y;
6960 buf_dp[1] = sound_dlg[9].x;
6961 buf_dp[2] = sound_dlg[9].y;
6962 sfx_dp[1] = sound_dlg[10].x;
6963 sfx_dp[2] = sound_dlg[10].y;
6964 pan_dp[1] = sound_dlg[11].x;
6965 pan_dp[2] = sound_dlg[11].y;
6966 sound_dlg[15].d2 = (midi_volume==255) ? 32 : midi_volume>>3;
6967 sound_dlg[16].d2 = (digi_volume==255) ? 32 : digi_volume>>3;
6968 sound_dlg[17].d2 = (emusic_volume==255) ? 32 : emusic_volume>>3;
6969 sound_dlg[18].d2 = zcmusic_bufsz;
6970 sound_dlg[19].d2 = (sfx_volume==255) ? 32 : sfx_volume>>3;
6971 sound_dlg[20].d2 = pan_style;
6972
6973 int32_t ret = zc_popup_dialog(sound_dlg,1);
6974
6975 if(ret==2)
6976 {
6977 master_volume(digi_volume,midi_volume);
6978 if (zcmusic)
6979 zcmusic_set_volume(zcmusic, emusic_volume);
6980
6981 int32_t temp_volume = sfx_volume;
6982 if (!get_qr(qr_OLD_SCRIPT_VOLUME))
6983 temp_volume = (sfx_volume * FFCore.usr_sfx_volume) / 10000 / 100;
6984 for(int32_t i=0; i<WAV_COUNT; ++i)
6985 {
6986 //allegro assertion fails when passing in -1 as voice -DD
6987 if(sfx_voice[i] > 0)
6988 voice_set_volume(sfx_voice[i], temp_volume);
6989 }
6990 zc_set_config(sfx_sect,"digi",digi_volume);
6991 zc_set_config(sfx_sect,"midi",midi_volume);
6992 zc_set_config(sfx_sect,"sfx",sfx_volume);
6993 zc_set_config(sfx_sect,"emusic",emusic_volume);
6994 zc_set_config(sfx_sect,"pan",pan_style);
6995 zc_set_config(sfx_sect,"zcmusic_bufsz",zcmusic_bufsz);
6996 }
6997 else
6998 {
6999 midi_volume = m;
7000 digi_volume = d;
7001 emusic_volume = e;
7002 zcmusic_bufsz = b;
7003 sfx_volume = s;
7004 pan_style = p;
7005 }
7006
7007 return D_O_K;
7008 }
7009
7010 int32_t queding(char const* s1, char const* s2, char const* s3)
7011 {
7012 return jwin_alert(ZC_str,s1,s2,s3,"&Yes","&No",'y','n',get_zc_font(font_lfont));
7013 }
7014
7015 int32_t onQuit()
7016 {
7017 if(Playing)
7018 {
7019 int32_t ret=0;
7020
7021 if(get_qr(qr_NOCONTINUE))
7022 {
7023 if(standalone_mode)
7024 {
7025 ret=queding("End current game?",
7026 "The continue screen is disabled; the game",
7027 "will be reloaded from the last save.");
7028 }
7029 else
7030 {
7031 ret=queding("End current game?",
7032 "The continue screen is disabled. You will",
7033 "be returned to the file select screen.");
7034 }
7035 }
7036 else
7037 ret=queding("End current game?",NULL,NULL);
7038
7039 if(ret==1)
7040 {
7041 disableClickToFreeze=false;
7042 Quit=qQUIT;
7043
7044 // Trying to evade a door repair charge?
7045 if(repaircharge)
7046 {
7047 game->change_drupy(-repaircharge);
7048 repaircharge=0;
7049 }
7050
7051 return D_CLOSE;
7052 }
7053 }
7054
7055 return D_O_K;
7056 }
7057
7058 int32_t onTryQuitMenu()
7059 {
7060 return onTryQuit(true);
7061 }
7062
7063 int32_t onTryQuit(bool inMenu)
7064 {
7065 if(Playing && !(GameFlags & GAMEFLAG_NO_F6))
7066 {
7067 if(active_cutscene.can_f6())
7068 {
7069 if(get_qr(qr_OLD_F6))
7070 {
7071 if(inMenu) onQuit();
7072 else /*if(!get_qr(qr_NOCONTINUE))*/ f_Quit(qQUIT);
7073 }
7074 else
7075 {
7076 disableClickToFreeze=false;
7077 GameFlags |= GAMEFLAG_TRYQUIT;
7078 }
7079 return D_CLOSE;
7080 }
7081 else active_cutscene.error();
7082 }
7083
7084 return D_O_K;
7085 }
7086
7087 int32_t onReset()
7088 {
7089 if(queding(" Reset system? ",NULL,NULL)==1)
7090 {
7091 disableClickToFreeze=false;
7092 Quit=qRESET;
7093 replay_quit();
7094 return D_CLOSE;
7095 }
7096
7097 return D_O_K;
7098 }
7099
7100 int32_t onExit()
7101 {
7102 if(queding(" Quit ZQuest Classic? ",NULL,NULL)==1)
7103 {
7104 Quit=qEXIT;
7105 return D_CLOSE;
7106 }
7107
7108 return D_O_K;
7109 }
7110
7111 int32_t onTitle_NES()
7112 {
7113 title_version=0;
7114 zc_set_config(cfg_sect,"title",title_version);
7115 return D_O_K;
7116 }
7117 int32_t onTitle_DX()
7118 {
7119 title_version=1;
7120 zc_set_config(cfg_sect,"title",title_version);
7121 return D_O_K;
7122 }
7123 int32_t onTitle_25()
7124 {
7125 title_version=2;
7126 zc_set_config(cfg_sect,"title",title_version);
7127 return D_O_K;
7128 }
7129
7130 int32_t onDebug()
7131 {
7132 if(debug_enabled)
7133 set_debug(!get_debug());
7134 return D_O_K;
7135 }
7136
7137 int32_t onHeartBeep()
7138 {
7139 heart_beep=!heart_beep;
7140 zc_set_config(cfg_sect,"heart_beep",heart_beep);
7141 return D_O_K;
7142 }
7143
7144 int32_t onSaveIndicator()
7145 {
7146 use_save_indicator = use_save_indicator ? 0 : 1;
7147 zc_set_config(cfg_sect,"save_indicator",use_save_indicator);
7148 return D_O_K;
7149 }
7150
7151 int32_t onEpilepsy()
7152 {
7153 if(jwin_alert3(
7154 "Epilepsy Flash Reduction",
7155 "Enabling this will reduce the intensity of flashing and screen wave effects.",
7156 "Disabling this will restore standard flash and wavy behaviour.",
7157 "Proceed?",
7158 "&Yes",
7159 "&No",
7160 NULL,
7161 'y',
7162 'n',
7163 0,
7164 get_zc_font(font_lfont)) == 1)
7165 {
7166 epilepsyFlashReduction = epilepsyFlashReduction ? 0 : 1;
7167 zc_set_config("zeldadx","checked_epilepsy",1);
7168 zc_set_config(cfg_sect,"epilepsy_flash_reduction",epilepsyFlashReduction);
7169 }
7170 return D_O_K;
7171 }
7172
7173 int32_t onTriforce()
7174 {
7175 for(int32_t i=0; i<MAXINITTABS; ++i)
7176 {
7177 init_tabs[i].flags&=~D_SELECTED;
7178 }
7179
7180 init_tabs[3].flags=D_SELECTED;
7181 return onCheatConsole();
7182 /*triforce_dlg[0].dp2=get_zc_font(font_lfont);
7183 for(int32_t i=1; i<=8; i++)
7184 triforce_dlg[i].flags = (game->lvlitems[i] & liTRIFORCE) ? D_SELECTED : 0;
7185
7186 if(zc_popup_dialog (triforce_dlg,-1)==9)
7187 {
7188 for(int32_t i=1; i<=8; i++)
7189 {
7190 game->lvlitems[i] &= ~liTRIFORCE;
7191 game->lvlitems[i] |= (triforce_dlg[i].flags & D_SELECTED) ? liTRIFORCE : 0;
7192 }
7193 }
7194 return D_O_K;*/
7195 }
7196
7197 bool rc = false;
7198 /*
7199 int32_t onEquipment()
7200 {
7201 for (int32_t i=0; i<MAXINITTABS; ++i)
7202 {
7203 init_tabs[i].flags&=~D_SELECTED;
7204 }
7205 init_tabs[0].flags=D_SELECTED;
7206 return onCheatConsole();
7207 }
7208 */
7209
7210 int32_t onItems()
7211 {
7212 for(int32_t i=0; i<MAXINITTABS; ++i)
7213 {
7214 init_tabs[i].flags&=~D_SELECTED;
7215 }
7216
7217 init_tabs[1].flags=D_SELECTED;
7218 return onCheatConsole();
7219 }
7220
7221 static DIALOG getnum_dlg[] =
7222 {
7223 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
7224 { jwin_win_proc, 80, 80, 160, 72, vc(0), vc(11), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
7225 { jwin_text_proc, 104, 104+4, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
7226 { jwin_edit_proc, 168, 104, 48, 16, 0, 0, 0, 0, 6, 0, NULL, NULL, NULL },
7227 { jwin_button_proc, 90, 126, 61, 21, vc(0), vc(11), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7228 { jwin_button_proc, 170, 126, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7229 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7230 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7231 };
7232
7233 int32_t getnumber(const char *prompt,int32_t initialval)
7234 {
7235 char buf[20];
7236 sprintf(buf,"%d",initialval);
7237 getnum_dlg[0].dp=(void *)prompt;
7238 getnum_dlg[0].dp2=get_zc_font(font_lfont);
7239 getnum_dlg[2].dp=buf;
7240
7241 large_dialog(getnum_dlg);
7242
7243 if(zc_popup_dialog(getnum_dlg,2)==3)
7244 return atoi(buf);
7245
7246 return initialval;
7247 }
7248
7249 int32_t onLife()
7250 {
7251 int value = vbound(getnumber("Life",game->get_life()),1,game->get_maxlife());
7252 cheats_enqueue(Cheat::Life, value);
7253 return D_O_K;
7254 }
7255
7256 int32_t onHeartC()
7257 {
7258 int max_life = vbound(getnumber("Heart Containers",game->get_maxlife()/game->get_hp_per_heart()),1,4095) * game->get_hp_per_heart();
7259 int life = vbound(getnumber("Life",game->get_life()/game->get_hp_per_heart()),1,max_life/game->get_hp_per_heart())*game->get_hp_per_heart();
7260 cheats_enqueue(Cheat::MaxLife, max_life);
7261 cheats_enqueue(Cheat::Life, life);
7262 return D_O_K;
7263 }
7264
7265 int32_t onMagicC()
7266 {
7267 int max_magic = vbound(getnumber("Magic Containers",game->get_maxmagic()/game->get_mp_per_block()),0,2047) * game->get_mp_per_block();
7268 int magic = vbound(getnumber("Magic",game->get_magic()/game->get_mp_per_block()),0,game->get_maxmagic()/game->get_mp_per_block())*game->get_mp_per_block();
7269 cheats_enqueue(Cheat::MaxMagic, max_magic);
7270 cheats_enqueue(Cheat::Magic, magic);
7271 return D_O_K;
7272 }
7273
7274 int32_t onRupies()
7275 {
7276 int value = vbound(getnumber("Rupees",game->get_rupies()),0,game->get_maxcounter(1));
7277 cheats_enqueue(Cheat::Rupies, value);
7278 return D_O_K;
7279 }
7280
7281 int32_t onMaxBombs()
7282 {
7283 int value = vbound(getnumber("Max Bombs",game->get_maxbombs()),0,0xFFFF);
7284 cheats_enqueue(Cheat::MaxBombs, value);
7285 cheats_enqueue(Cheat::Bombs, value);
7286 return D_O_K;
7287 }
7288
7289 int32_t onRefillLife()
7290 {
7291 cheats_enqueue(Cheat::Life, game->get_maxlife());
7292 return D_O_K;
7293 }
7294 int32_t onRefillMagic()
7295 {
7296 cheats_enqueue(Cheat::Magic, game->get_maxmagic());
7297 return D_O_K;
7298 }
7299 int32_t onClock()
7300 {
7301 cheats_enqueue(Cheat::Clock);
7302 return D_O_K;
7303 }
7304
7305 int32_t onQstPath()
7306 {
7307 char path[2048];
7308
7309 chop_path(qstdir);
7310 strcpy(path,qstdir);
7311
7312 go();
7313
7314 if(jwin_dfile_select_ex("Quest File Directory", path, "qst", 2048, -1, -1, get_zc_font(font_lfont)))
7315 {
7316 chop_path(path);
7317 fix_filename_case(path);
7318 fix_filename_slashes(path);
7319 strcpy(qstdir,path);
7320 strcpy(qstpath,qstdir);
7321 }
7322
7323 comeback();
7324 return D_O_K;
7325 }
7326
7327 #include "dialog/cheat_dialog.h"
7328 int32_t onCheat()
7329 {
7330 call_setcheat_dialog();
7331 game->set_cheat(maxcheat);
7332 if(cheat) game->did_cheat(true);
7333 return D_O_K;
7334 }
7335
7336 int32_t onCheatRupies()
7337 {
7338 cheats_enqueue(Cheat::Rupies, game->get_maxcounter(1));
7339 return D_O_K;
7340 }
7341
7342 int32_t onCheatArrows()
7343 {
7344 cheats_enqueue(Cheat::Arrows, game->get_maxarrows());
7345 return D_O_K;
7346 }
7347
7348 int32_t onCheatBombs()
7349 {
7350 cheats_enqueue(Cheat::Bombs, game->get_maxbombs(), game->get_maxcounter(6));
7351 return D_O_K;
7352 }
7353
7354 // *** screen saver
7355
7356 9285364 int32_t after_time()
7357 {
7358
1/2
✓ Branch 0 taken 9285364 times.
✗ Branch 1 not taken.
9285364 if(ss_enable == 0)
7359 return INT_MAX;
7360
7361
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9285364 times.
9285364 if(ss_after <= 0)
7362 return 5 * 60;
7363
7364
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9285364 times.
9285364 if(ss_after <= 3)
7365 return ss_after * 15 * 60;
7366
7367
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9285364 times.
9285364 if(ss_after <= 13)
7368 return (ss_after - 3) * 60 * 60;
7369
7370 9285364 return MAX_IDLE + 1;
7371 9285364 }
7372
7373 static const char *after_str[15] =
7374 {
7375 " 5 sec", "15 sec", "30 sec", "45 sec", " 1 min", " 2 min", " 3 min",
7376 " 4 min", " 5 min", " 6 min", " 7 min", " 8 min", " 9 min", "10 min",
7377 "Never"
7378 };
7379
7380 const char *after_list(int32_t index, int32_t *list_size)
7381 {
7382 if(index < 0)
7383 {
7384 *list_size = 15;
7385 return NULL;
7386 }
7387
7388 return after_str[index];
7389 }
7390
7391 114 static ListData after__list(after_list, &font);
7392
7393 static DIALOG scrsaver_dlg[] =
7394 {
7395 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
7396 114 { jwin_win_proc, 32, 64, 256, 136, 0, 0, 0, D_EXIT, 0, 0, (void *) "Screen Saver Settings", NULL, NULL },
7397 114 { jwin_frame_proc, 42, 92, 236, 70, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
7398 114 { jwin_text_proc, 60, 104, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Run After", NULL, NULL },
7399 114 { jwin_text_proc, 60, 128, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Speed", NULL, NULL },
7400 114 { jwin_text_proc, 60, 144, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Density", NULL, NULL },
7401 114 { jwin_droplist_proc, 144, 100, 96, 16, 0, 0, 0, 0, 0, 0, (void *) &after__list, NULL, NULL },
7402 114 { jwin_slider_proc, 144, 128, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7403 114 { jwin_slider_proc, 144, 144, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7404 114 { jwin_button_proc, 42, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7405 114 { jwin_button_proc, 124, 170, 72, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Preview", NULL, NULL },
7406 114 { jwin_button_proc, 218, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7407 114 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7408 114 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7409 };
7410
7411 int32_t onScreenSaver()
7412 {
7413 scrsaver_dlg[0].dp2=get_zc_font(font_lfont);
7414 int32_t oldcfgs[3];
7415 scrsaver_dlg[5].d1 = scrsaver_dlg[5].d2 = oldcfgs[0] = ss_after;
7416 scrsaver_dlg[6].d2 = oldcfgs[1] = ss_speed;
7417 scrsaver_dlg[7].d2 = oldcfgs[2] = ss_density;
7418
7419 large_dialog(scrsaver_dlg);
7420
7421 int32_t ret = zc_popup_dialog(scrsaver_dlg,-1);
7422
7423 if(ret == 8 || ret == 9)
7424 {
7425 ss_after = scrsaver_dlg[5].d1;
7426 ss_speed = scrsaver_dlg[6].d2;
7427 ss_density = scrsaver_dlg[7].d2;
7428 if(oldcfgs[0] != ss_after)
7429 zc_set_config(cfg_sect,"ss_after",ss_after);
7430 if(oldcfgs[1] != ss_speed)
7431 zc_set_config(cfg_sect,"ss_speed",ss_speed);
7432 if(oldcfgs[2] != ss_density)
7433 zc_set_config(cfg_sect,"ss_density",ss_density);
7434 }
7435
7436 if(ret == 9)
7437 // preview Screen Saver
7438 {
7439 clear_keybuf();
7440 Matrix(ss_speed, ss_density, 30);
7441 system_pal(true);
7442 sys_mouse();
7443 }
7444
7445 return D_O_K;
7446 }
7447
7448 /***** Menus *****/
7449
7450 static MENU game_menu[] =
7451 {
7452 { (char *)"&Continue\tESC", onContinue, NULL, 0, NULL },
7453 { (char *)"", NULL, NULL, 0, NULL },
7454 { (char *)"L&oad Quest...", onCustomGame, NULL, 0, NULL },
7455 { (char *)"&End Game\tF6", onTryQuitMenu, NULL, 0, NULL },
7456 { (char *)"", NULL, NULL, 0, NULL },
7457 #ifdef __EMSCRIPTEN__
7458 { (char *)"&Reset\tF7", onReset, NULL, 0, NULL },
7459 #elif defined(ALLEGRO_MACOSX)
7460 { (char *)"&Reset\tF7", onReset, NULL, 0, NULL },
7461 { (char *)"&Quit\tF8", onExit, NULL, 0, NULL },
7462 #else
7463 { (char *)"&Reset\tF9", onReset, NULL, 0, NULL },
7464 { (char *)"&Quit\tF10", onExit, NULL, 0, NULL },
7465 #endif
7466 { NULL, NULL, NULL, 0, NULL }
7467 };
7468
7469 static MENU title_menu[] =
7470 {
7471 { (char *)"&Original", onTitle_NES, NULL, 0, NULL },
7472 { (char *)"&ZQuest Classic", onTitle_DX, NULL, 0, NULL },
7473 { (char *)"ZQuest Classic &2.50", onTitle_25, NULL, 0, NULL },
7474 { NULL, NULL, NULL, 0, NULL }
7475 };
7476
7477 static MENU snapshot_format_menu[] =
7478 {
7479 { (char *)"&BMP", onSetSnapshotFormat, NULL, 0, NULL },
7480 { (char *)"&GIF", onSetSnapshotFormat, NULL, 0, NULL },
7481 { (char *)"&JPG", onSetSnapshotFormat, NULL, 0, NULL },
7482 { (char *)"&PNG", onSetSnapshotFormat, NULL, 0, NULL },
7483 { (char *)"PC&X", onSetSnapshotFormat, NULL, 0, NULL },
7484 { (char *)"&TGA", onSetSnapshotFormat, NULL, 0, NULL },
7485 { NULL, NULL, NULL, 0, NULL }
7486 };
7487
7488 static MENU controls_menu[] =
7489 {
7490 { (char *)"Key&board...", onKeyboard, NULL, 0, NULL },
7491 { (char *)"&Gamepad...", onGamepad, NULL, 0, NULL },
7492 { (char *)"&Cheat Keys...", onCheatKeys, NULL, 0, NULL },
7493 { NULL, NULL, NULL, 0, NULL }
7494 };
7495
7496 static MENU name_entry_mode_menu[] =
7497 {
7498 { (char *)"&Keyboard", onKeyboardEntry, NULL, 0, NULL },
7499 { (char *)"&Letter Grid", onLetterGridEntry, NULL, 0, NULL },
7500 { (char *)"&Extended Letter Grid", onExtLetterGridEntry, NULL, 0, NULL },
7501 { NULL, NULL, NULL, 0, NULL }
7502 };
7503
7504 static void set_controls_menu_active()
7505 {
7506
7507 }
7508
7509 static MENU window_menu[] =
7510 {
7511 { "Lock Aspect Ratio", onDragAspect, NULL, 0, NULL },
7512 { "Lock Integer Scale", onIntegerScaling, NULL, 0, NULL },
7513 { "Save Size Changes", onSaveDragResize, NULL, 0, NULL },
7514 { "Save Position Changes", onWinPosSave, NULL, 0, NULL },
7515 { "Stretch Game Area", onStretchGame, NULL, 0, NULL },
7516 { NULL, NULL, NULL, 0, NULL }
7517 };
7518 static MENU options_menu[] =
7519 {
7520 { "&Title Screen", NULL, title_menu, 0, NULL },
7521 { "Name &Entry Mode", NULL, name_entry_mode_menu, 0, NULL },
7522 { "S&napshot Format", NULL, snapshot_format_menu, 0, NULL },
7523 { "&Window Settings", NULL, window_menu, 0, NULL },
7524 { "Epilepsy Flash Reduction", onEpilepsy, NULL, 0, NULL },
7525 { "Pause In Background", onPauseInBackground, NULL, 0, NULL },
7526 { NULL, NULL, NULL, 0, NULL }
7527 };
7528 static MENU settings_menu[] =
7529 {
7530 { "&Sound...", onSound, NULL, 0, NULL },
7531 { "C&ontrols", NULL, controls_menu, 0, NULL },
7532 { "", NULL, NULL, 0, NULL },
7533 { "Options", NULL, options_menu, 0, NULL },
7534 { "", NULL, NULL, 0, NULL },
7535 //
7536 { "&Cap FPS\tF1", onVsync, NULL, 0, NULL },
7537 { "Show &FPS\tF2", onShowFPS, NULL, 0, NULL },
7538 { "Click to Freeze", onClickToFreeze, NULL, 0, NULL },
7539 { "Cont. &Heart Beep", onHeartBeep, NULL, 0, NULL },
7540 { "Show Trans. &Layers", onTransLayers, NULL, 0, NULL },
7541 //
7542 { "Up+A+B To &Quit", onNESquit, NULL, 0, NULL },
7543 { "Volume &Keys", onVolKeys, NULL, 0, NULL },
7544 { "Sa&ve Indicator", onSaveIndicator, NULL, 0, NULL },
7545 { "", NULL, NULL, 0, NULL },
7546 { "Debu&g", onDebug, NULL, 0, NULL },
7547 //
7548 { NULL, NULL, NULL, 0, NULL }
7549 };
7550
7551
7552 static MENU misc_menu[] =
7553 {
7554 { (char *)"&About...", onAbout, NULL, 0, NULL },
7555 { (char *)"&Credits...", onCredits, NULL, 0, NULL },
7556 { (char *)"&Fullscreen", onFullscreenMenu, NULL, 0, NULL },
7557 { (char *)"&Video Mode...", onVidMode, NULL, 0, NULL },
7558 { (char *)"", NULL, NULL, 0, NULL },
7559 //5
7560 { (char *)"&Quest Info...", onQuest, NULL, 0, NULL },
7561 { (char *)"Quest &MIDI Info...", onMIDICredits, NULL, 0, NULL },
7562 { (char *)"Quest &Directory...", onQstPath, NULL, 0, NULL },
7563 { (char *)"", NULL, NULL, 0, NULL },
7564 { (char *)"Take &Snapshot\tF12", onSnapshot, NULL, 0, NULL },
7565 //10
7566 { (char *)"Sc&reen Saver...", onScreenSaver, NULL, 0, NULL },
7567 { (char *)"Save ZC Configuration", OnSaveZCConfig, NULL, 0, NULL },
7568 { (char *)"Show ZASM Debugger", onConsoleZASM, NULL, 0, NULL },
7569 { (char *)"Show ZScript Debugger", onConsoleZScript, NULL, 0, NULL },
7570 { (char *)"Clear Console on Qst Load", onClrConsoleOnLoad, NULL, 0, NULL },
7571 //15
7572 { (char *)"Clear Directory Cache", OnnClearQuestDir, NULL, 0, NULL },
7573 { (char *)"Modules", NULL, zcmodule_menu, 0, NULL },
7574 { NULL, NULL, NULL, 0, NULL }
7575 };
7576
7577 static MENU refill_menu[] =
7578 {
7579 { (char *)"&Life", onRefillLife, NULL, 0, NULL },
7580 { (char *)"&Magic", onRefillMagic, NULL, 0, NULL },
7581 { (char *)"&Bombs", onCheatBombs, NULL, 0, NULL },
7582 { (char *)"&Rupees", onCheatRupies, NULL, 0, NULL },
7583 { (char *)"&Arrows", onCheatArrows, NULL, 0, NULL },
7584 { NULL, NULL, NULL, 0, NULL }
7585 };
7586
7587 static MENU show_menu[] =
7588 {
7589 { (char *)"Combos", onShowLayer0, NULL, 0, NULL },
7590 { (char *)"Layer 1", onShowLayer1, NULL, 0, NULL },
7591 { (char *)"Layer 2", onShowLayer2, NULL, 0, NULL },
7592 { (char *)"Layer 3", onShowLayer3, NULL, 0, NULL },
7593 { (char *)"Layer 4", onShowLayer4, NULL, 0, NULL },
7594 { (char *)"Layer 5", onShowLayer5, NULL, 0, NULL },
7595 { (char *)"Layer 6", onShowLayer6, NULL, 0, NULL },
7596 { (char *)"Overhead Combos", onShowLayerO, NULL, 0, NULL },
7597 { (char *)"Push Blocks", onShowLayerP, NULL, 0, NULL },
7598 { (char *)"Freeform Combos", onShowLayerF, NULL, 0, NULL },
7599 { (char *)"Sprites", onShowLayerS, NULL, 0, NULL },
7600 { (char *)"", NULL, NULL, 0, NULL },
7601 { (char *)"Current FFC Scripts", onShowFFScripts, NULL, 0, NULL },
7602 { (char *)"", NULL, NULL, 0, NULL },
7603 { (char *)"Walkability", onShowLayerW, NULL, 0, NULL },
7604 { (char *)"Hitboxes", onShowHitboxes, NULL, 0, NULL },
7605 { (char *)"Effects", onShowLayerE, NULL, 0, NULL },
7606 { (char *)"Info Opacity", onShowInfoOpacity, NULL, 0, NULL },
7607 { NULL, NULL, NULL, 0, NULL }
7608 };
7609
7610 static MENU cheat_menu[] =
7611 {
7612 { (char *)"Set &Cheat", onCheat, NULL, 0, NULL },
7613 { (char *)"", NULL, NULL, 0, NULL },
7614 { (char *)"Re&fill", NULL, refill_menu, 0, NULL },
7615 { (char *)"", NULL, NULL, 0, NULL },
7616 { (char *)"&Invincible", onClock, NULL, 0, NULL },
7617 { (char *)"Ma&x Bombs...", onMaxBombs, NULL, 0, NULL },
7618 { (char *)"&Heart Containers...", onHeartC, NULL, 0, NULL },
7619 { (char *)"&Magic Containers...", onMagicC, NULL, 0, NULL },
7620 { (char *)"", NULL, NULL, 0, NULL },
7621 { (char *)"&Player Data...", onCheatConsole, NULL, 0, NULL },
7622 { (char *)"", NULL, NULL, 0, NULL },
7623 { (char *)"Walk Through &Walls", onNoWalls, NULL, 0, NULL },
7624 { (char *)"Player Ignores Side&view", onIgnoreSideview, NULL, 0, NULL },
7625 { (char *)"&Quick Movement", onGoFast, NULL, 0, NULL },
7626 { (char *)"&Kill All Enemies", onKillCheat, NULL, 0, NULL },
7627 { (char *)"Trigger &Secrets", onSecretsCheat, NULL, 0, NULL },
7628 { (char *)"Trigger Secrets Perm", onSecretsCheatPerm, NULL, 0, NULL },
7629 { (char *)"Show/Hide Layer", NULL, show_menu, 0, NULL },
7630 { (char *)"Toggle &Light", onLightSwitch, NULL, 0, NULL },
7631 { (char *)"&Goto Location...", onGoTo, NULL, 0, NULL },
7632 { NULL, NULL, NULL, 0, NULL }
7633 };
7634
7635 #if DEVLEVEL > 0
7636 int32_t devLogging();
7637 int32_t devDebug();
7638 int32_t devTimestmp();
7639 #if DEVLEVEL > 1
7640 int32_t setCheat();
7641 #endif //DEVLEVEL > 1
7642 enum
7643 {
7644 dv_log,
7645 // dv_dbg,
7646 dv_tmpstmp,
7647 #if DEVLEVEL > 1
7648 dv_nil,
7649 dv_setcheat,
7650 #endif //DEVLEVEL > 1
7651 dv_max
7652 };
7653 static MENU dev_menu[] =
7654 {
7655 { (char *)"&Force Error Log", devLogging, NULL, 0, NULL },
7656 // { (char *)"&Extra Debug Log", devDebug, NULL, 0, NULL },
7657 { (char *)"&Timestamp Log", devTimestmp, NULL, 0, NULL },
7658 #if DEVLEVEL > 1
7659 { (char *)"", NULL, NULL, 0, NULL },
7660 { (char *)"Set &Cheat", setCheat, NULL, 0, NULL },
7661 #endif //DEVLEVEL > 1
7662 { NULL, NULL, NULL, 0, NULL }
7663 };
7664 int32_t devLogging()
7665 {
7666 dev_logging = !dev_logging;
7667 dev_menu[dv_log].flags = dev_logging ? D_SELECTED : 0;
7668 return D_O_K;
7669 }
7670 // int32_t devDebug()
7671 // {
7672 // dev_debug = !dev_debug;
7673 // dev_menu[dv_dbg].flags = dev_debug ? D_SELECTED : 0;
7674 // return D_O_K;
7675 // }
7676 int32_t devTimestmp()
7677 {
7678 dev_timestmp = !dev_timestmp;
7679 dev_menu[dv_tmpstmp].flags = dev_timestmp ? D_SELECTED : 0;
7680 return D_O_K;
7681 }
7682 #if DEVLEVEL > 1
7683 int32_t setCheat()
7684 {
7685 cheat = (vbound(getnumber("Cheat Level",cheat), 0, 4));
7686 return D_O_K;
7687 }
7688 #endif //DEVLEVEL > 1
7689 #endif //DEVLEVEL > 0
7690
7691 MENU the_player_menu[] =
7692 {
7693 { (char *)"&Game", NULL, game_menu, 0, NULL },
7694 { (char *)"&Settings", NULL, settings_menu, 0, NULL },
7695 { (char *)"&Cheat", NULL, cheat_menu, 0, NULL },
7696 { (char *)"Replay", NULL, replay_menu, 0, NULL },
7697 { (char *)"&ZC", NULL, misc_menu, 0, NULL },
7698 #if DEVLEVEL > 0
7699 { (char *)"&Dev", NULL, dev_menu, 0, NULL },
7700 #endif
7701 { NULL, NULL, NULL, 0, NULL }
7702 };
7703 int32_t onPauseInBackground()
7704 {
7705 if(jwin_alert3(
7706 "Toggle Pause In Background",
7707 "This action will change whether ZC Player pauses when the window loses focus.",
7708 "",
7709 "Proceed?",
7710 "&Yes",
7711 "&No",
7712 NULL,
7713 'y',
7714 'n',
7715 0,
7716 get_zc_font(font_lfont)) == 1)
7717 {
7718 pause_in_background = pause_in_background ? 0 : 1;
7719 zc_set_config("zeldadx","pause_in_background", pause_in_background);
7720 int switch_type = pause_in_background ? SWITCH_PAUSE : SWITCH_BACKGROUND;
7721 set_display_switch_mode(fullscreen?SWITCH_BACKAMNESIA:switch_type);
7722 set_display_switch_callback(SWITCH_OUT, switch_out_callback);
7723 set_display_switch_callback(SWITCH_IN, switch_in_callback);
7724 }
7725 options_menu[5].flags =(pause_in_background)?D_SELECTED:0;
7726 return D_O_K;
7727 }
7728
7729 int32_t onKeyboardEntry()
7730 {
7731 NameEntryMode=0;
7732 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7733 return D_O_K;
7734 }
7735
7736 int32_t onLetterGridEntry()
7737 {
7738 NameEntryMode=1;
7739 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7740 return D_O_K;
7741 }
7742
7743 int32_t onExtLetterGridEntry()
7744 {
7745 NameEntryMode=2;
7746 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7747 return D_O_K;
7748 }
7749
7750 static BITMAP* oldscreen;
7751 int32_t onFullscreenMenu()
7752 {
7753 // super hacks
7754 screen = oldscreen;
7755 if (onFullscreen() == D_REDRAW)
7756 {
7757 oldscreen = screen;
7758 }
7759 screen = menu_bmp;
7760 misc_menu[2].flags =(isFullScreen()==1)?D_SELECTED:0;
7761 return D_O_K;
7762 }
7763
7764 114 void fix_menu()
7765 {
7766
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(!debug_enabled)
7767 114 settings_menu[13].text = NULL;
7768 114 }
7769
7770 static DIALOG system_dlg[] =
7771 {
7772 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
7773 { jwin_menu_proc, 0, 0, 0, 0, 0, 0, 0, D_USER, 0, 0, (void *) the_player_menu, NULL, NULL },
7774 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onVsync, NULL, NULL },
7775 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F2, 0, (void *) onShowFPS, NULL, NULL },
7776 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F6, 0, (void *) onTryQuitMenu, NULL, NULL },
7777 #ifndef ALLEGRO_MACOSX
7778 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F9, 0, (void *) onReset, NULL, NULL },
7779 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F10, 0, (void *) onExit, NULL, NULL },
7780 #else
7781 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F7, 0, (void *) onReset, NULL, NULL },
7782 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F8, 0, (void *) onExit, NULL, NULL },
7783 #endif
7784 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F12, 0, (void *) onSnapshot, NULL, NULL },
7785 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_TAB, 0, (void *) onDebug, NULL, NULL },
7786 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7787 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7788 };
7789
7790 void reset_snapshot_format_menu()
7791 {
7792 for(int32_t i=0; i<ssfmtMAX; ++i)
7793 {
7794 snapshot_format_menu[i].flags=0;
7795 }
7796 }
7797
7798 int32_t onSetSnapshotFormat()
7799 {
7800 switch(active_menu->text[1])
7801 {
7802 case 'B': //"&BMP"
7803 SnapshotFormat=0;
7804 break;
7805
7806 case 'G': //"&GIF"
7807 SnapshotFormat=1;
7808 break;
7809
7810 case 'J': //"&JPG"
7811 SnapshotFormat=2;
7812 break;
7813
7814 case 'P': //"&PNG"
7815 SnapshotFormat=3;
7816 break;
7817
7818 case 'C': //"PC&X"
7819 SnapshotFormat=4;
7820 break;
7821
7822 case 'T': //"&TGA"
7823 SnapshotFormat=5;
7824 break;
7825
7826 case 'L': //"&LBM"
7827 SnapshotFormat=6;
7828 break;
7829 }
7830 zc_set_config("zeldadx", "snapshot_format", SnapshotFormat);
7831
7832 snapshot_format_menu[SnapshotFormat].flags=D_SELECTED;
7833 return D_O_K;
7834 }
7835
7836
7837 void color_layer(RGB *src,RGB *dest,char r,char g,char b,char pos,int32_t from,int32_t to)
7838 {
7839 PALETTE tmp;
7840
7841 for(int32_t i=0; i<256; i++)
7842 {
7843 tmp[i].r=r;
7844 tmp[i].g=g;
7845 tmp[i].b=b;
7846 }
7847
7848 fade_interpolate(src,tmp,dest,pos,from,to);
7849 }
7850
7851 14 void system_pal(bool force)
7852 {
7853
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14 if(is_sys_pal && !force) return;
7854 14 is_sys_pal = true;
7855 14 load_colorset(gui_colorset, syspal, jwin_a5_colors);
7856 14 hw_palette = &syspal;
7857 14 update_hw_pal = true;
7858 14 }
7859
7860 static uint32_t entered_sys_pal = 0;
7861 14 void enter_sys_pal()
7862 {
7863
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(is_sys_pal)
7864 {
7865 if(entered_sys_pal)
7866 ++entered_sys_pal;
7867 return;
7868 }
7869 14 sys_mouse();
7870 14 system_pal(true);
7871 14 ++entered_sys_pal;
7872 14 }
7873 14 void exit_sys_pal()
7874 {
7875
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(entered_sys_pal)
7876 {
7877
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(!--entered_sys_pal)
7878 {
7879 14 game_pal();
7880 14 game_mouse();
7881 14 }
7882 14 }
7883 14 }
7884
7885 void switch_out_callback()
7886 {
7887 if (pause_in_background && !MenuOpen)
7888 {
7889 System();
7890 }
7891 }
7892
7893 void switch_in_callback()
7894 {
7895 }
7896
7897 421 void game_pal()
7898 {
7899 421 is_sys_pal = false;
7900 421 entered_sys_pal = 0;
7901 421 hw_palette = &RAMpal;
7902 421 update_hw_pal = true;
7903 421 }
7904
7905 static char bar_str[] = "";
7906
7907 14 void music_pause()
7908 {
7909 //al_pause_duh(tmplayer);
7910 14 zcmusic_pause(zcmusic, ZCM_PAUSE);
7911
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(zcmixer->oldtrack)
7912 zcmusic_pause(zcmixer->oldtrack, ZCM_PAUSE);
7913 14 zc_midi_pause();
7914 14 }
7915
7916 void music_resume()
7917 {
7918 //al_resume_duh(tmplayer);
7919 zcmusic_pause(zcmusic, ZCM_RESUME);
7920 if (zcmixer->oldtrack)
7921 zcmusic_pause(zcmixer->oldtrack, ZCM_RESUME);
7922 zc_midi_resume();
7923 }
7924
7925 3358 void music_stop()
7926 {
7927 //al_stop_duh(tmplayer);
7928 //unload_duh(tmusic);
7929 //tmusic=NULL;
7930 //tmplayer=NULL;
7931 3358 zcmusic_stop(zcmusic);
7932 3358 zcmusic_unload_file(zcmusic);
7933
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3358 times.
3358 if (zcmixer->oldtrack)
7934 {
7935 zcmusic_stop(zcmixer->oldtrack);
7936 zcmusic_unload_file(zcmixer->oldtrack);
7937 }
7938 //if (zcmixer->newtrack)
7939 //{
7940 // zcmusic_stop(zcmixer->newtrack);
7941 // zcmusic_unload_file(zcmixer->newtrack);
7942 //}
7943 3358 zc_stop_midi();
7944 3358 currmidi=-1;
7945 3358 }
7946
7947 void System()
7948 {
7949 mouse_down=gui_mouse_b();
7950 music_pause();
7951 pause_all_sfx();
7952 MenuOpen = true;
7953 enter_sys_pal();
7954 // FONT *oldfont=font;
7955 // font=tfont;
7956
7957 misc_menu[2].flags =(isFullScreen()==1)?D_SELECTED:0;
7958 misc_menu[3].flags =(isFullScreen()==1)?D_DISABLED:0;
7959
7960 game_menu[2].flags = getsaveslot() > -1 ? 0 : D_DISABLED;
7961 #if DEVLEVEL > 1
7962 dev_menu[dv_setcheat].flags = Playing ? 0 : D_DISABLED;
7963 #endif
7964 game_menu[3].flags =
7965 misc_menu[5].flags = Playing ? 0 : D_DISABLED;
7966 misc_menu[7].flags = !Playing ? 0 : D_DISABLED;
7967 clear_keybuf();
7968
7969 DIALOG_PLAYER *p;
7970
7971 clear_bitmap(menu_bmp);
7972 oldscreen = screen;
7973 screen = menu_bmp;
7974
7975 p = init_dialog(system_dlg,-1);
7976
7977 // drop the menu on startup if menu button pressed
7978 if(joybtn(Mbtn)||zc_getrawkey(KEY_ESC))
7979 simulate_keypress(KEY_G << 8);
7980
7981 do
7982 {
7983 if(close_button_quit)
7984 {
7985 close_button_quit = false;
7986 f_Quit(qEXIT);
7987 if(Quit) break;
7988 }
7989 rest(17);
7990
7991 if(mouse_down && !gui_mouse_b())
7992 mouse_down=0;
7993
7994 title_menu[0].flags = (title_version==0) ? D_SELECTED : 0;
7995 title_menu[1].flags = (title_version==1) ? D_SELECTED : 0;
7996 title_menu[2].flags = (title_version==2) ? D_SELECTED : 0;
7997
7998 settings_menu[1].flags = replay_is_replaying() ? D_DISABLED : 0;
7999 settings_menu[5].flags = Throttlefps?D_SELECTED:0;
8000 settings_menu[6].flags = ShowFPS?D_SELECTED:0;
8001 settings_menu[7].flags = ClickToFreeze?D_SELECTED:0;
8002 settings_menu[9].flags = TransLayers?D_SELECTED:0;
8003 settings_menu[10].flags = NESquit?D_SELECTED:0;
8004 settings_menu[11].flags = volkeys?D_SELECTED:0;
8005
8006 window_menu[0].flags = DragAspect?D_SELECTED:0;
8007 window_menu[1].flags = scaleForceInteger?D_SELECTED:0;
8008 window_menu[2].flags = SaveDragResize?D_SELECTED:0;
8009 window_menu[3].flags = SaveWinPos?D_SELECTED:0;
8010 window_menu[4].flags = stretchGame?D_SELECTED:0;
8011
8012 options_menu[4].flags = (epilepsyFlashReduction) ? D_SELECTED : 0;
8013 options_menu[5].flags = (pause_in_background)?D_SELECTED:0;
8014
8015 name_entry_mode_menu[0].flags = (NameEntryMode==0)?D_SELECTED:0;
8016 name_entry_mode_menu[1].flags = (NameEntryMode==1)?D_SELECTED:0;
8017 name_entry_mode_menu[2].flags = (NameEntryMode==2)?D_SELECTED:0;
8018
8019 misc_menu[12].flags =(zasm_debugger)?D_SELECTED:0;
8020 misc_menu[13].flags =(zscript_debugger)?D_SELECTED:0;
8021 misc_menu[14].flags =(clearConsoleOnLoad)?D_SELECTED:0;
8022
8023 bool nocheat = (replay_is_replaying() || !Playing
8024 || (!zcheats.flags && !get_debug() && DEVLEVEL < 2 && !zqtesting_mode && !devpwd()));
8025 the_player_menu[2].flags = nocheat ? D_DISABLED : 0;
8026 cheat_menu[0].flags = 0;
8027 refill_menu[4].flags = get_qr(qr_TRUEARROWS) ? 0 : D_DISABLED;
8028 cheat_menu[1].text = (cheat >= 1) || get_debug() ? bar_str : NULL;
8029 cheat_menu[3].text = (cheat >= 2) || get_debug() ? bar_str : NULL;
8030 cheat_menu[8].text = (cheat >= 3) || get_debug() ? bar_str : NULL;
8031 cheat_menu[10].text = (cheat >= 4) || get_debug() ? bar_str : NULL;
8032 cheat_menu[4].flags = getClock() ? D_SELECTED : 0;
8033 cheat_menu[11].flags = toogam ? D_SELECTED : 0;
8034 cheat_menu[12].flags = ignoreSideview ? D_SELECTED : 0;
8035 cheat_menu[13].flags = gofast ? D_SELECTED : 0;
8036
8037 show_menu[0].flags = show_layer_0 ? D_SELECTED : 0;
8038 show_menu[1].flags = show_layer_1 ? D_SELECTED : 0;
8039 show_menu[2].flags = show_layer_2 ? D_SELECTED : 0;
8040 show_menu[3].flags = show_layer_3 ? D_SELECTED : 0;
8041 show_menu[4].flags = show_layer_4 ? D_SELECTED : 0;
8042 show_menu[5].flags = show_layer_5 ? D_SELECTED : 0;
8043 show_menu[6].flags = show_layer_6 ? D_SELECTED : 0;
8044 show_menu[7].flags = show_layer_over ? D_SELECTED : 0;
8045 show_menu[8].flags = show_layer_push ? D_SELECTED : 0;
8046 show_menu[9].flags = show_sprites ? D_SELECTED : 0;
8047 show_menu[10].flags = show_ffcs ? D_SELECTED : 0;
8048 show_menu[12].flags = show_walkflags ? D_SELECTED : 0;
8049 show_menu[13].flags = show_ff_scripts ? D_SELECTED : 0;
8050 show_menu[14].flags = show_hitboxes ? D_SELECTED : 0;
8051 show_menu[15].flags = show_effectflags ? D_SELECTED : 0;
8052
8053 settings_menu[8].flags = heart_beep ? D_SELECTED : 0;
8054 settings_menu[12].flags = use_save_indicator ? D_SELECTED : 0;
8055
8056 replay_menu[0].text = zc_get_config("zeldadx", "replay_new_saves", false) ?
8057 (char *)"Disable recording new saves" :
8058 (char *)"Enable recording new saves";
8059 replay_menu[1].flags = replay_is_active() ? 0 : D_DISABLED;
8060 replay_menu[1].text = replay_get_mode() == ReplayMode::Record ?
8061 (char *)"Stop recording" :
8062 (char *)"Stop replaying";
8063 replay_menu[5].flags = replay_get_mode() == ReplayMode::Record ? 0 : D_DISABLED;
8064 replay_menu[6].text = replay_is_snapshot_all_frames() ?
8065 (char *)"Disable snapshot all frames" :
8066 (char *)"Enable snapshot all frames";
8067
8068 reset_snapshot_format_menu();
8069 snapshot_format_menu[SnapshotFormat].flags = D_SELECTED;
8070
8071 if(debug_enabled)
8072 {
8073 settings_menu[14].flags = get_debug() ? D_SELECTED : 0;
8074 }
8075
8076 if(gui_mouse_b() && !mouse_down)
8077 break;
8078
8079 // press menu to drop the menu
8080 if(rMbtn())
8081 simulate_keypress(KEY_G << 8);
8082
8083 if(input_idle(true) > after_time())
8084 // run Screeen Saver
8085 {
8086 // Screen saver enabled for now.
8087 clear_keybuf();
8088 Matrix(ss_speed, ss_density, 0);
8089 system_pal(true);
8090 sys_mouse();
8091 broadcast_dialog_message(MSG_DRAW, 0);
8092 }
8093
8094 update_hw_screen();
8095 }
8096 while(update_dialog(p));
8097
8098 screen = oldscreen;
8099
8100 // font=oldfont;
8101 mouse_down=gui_mouse_b();
8102 shutdown_dialog(p);
8103 MenuOpen = false;
8104 if(Quit)
8105 {
8106 kill_sfx();
8107 music_stop();
8108 update_hw_screen();
8109 }
8110 else
8111 {
8112 music_resume();
8113 resume_all_sfx();
8114
8115 if(rc)
8116 ringcolor(false);
8117 }
8118 exit_sys_pal();
8119
8120 eat_buttons();
8121
8122 rc=false;
8123 clear_keybuf();
8124 // text_mode(0);
8125 }
8126
8127 114 void fix_dialogs()
8128 {
8129 114 jwin_center_dialog(about_dlg);
8130 114 jwin_center_dialog(gamepad_dlg);
8131 114 jwin_center_dialog(credits_dlg);
8132 114 jwin_center_dialog(gamemode_dlg);
8133 114 jwin_center_dialog(getnum_dlg);
8134 114 jwin_center_dialog(goto_dlg);
8135 114 jwin_center_dialog(keyboard_control_dlg);
8136 114 jwin_center_dialog(midi_dlg);
8137 114 jwin_center_dialog(quest_dlg);
8138 114 jwin_center_dialog(scrsaver_dlg);
8139 114 jwin_center_dialog(sound_dlg);
8140 114 jwin_center_dialog(triforce_dlg);
8141
8142 // digi_dp[1] += scrx;
8143 // digi_dp[2] += scry;
8144 // midi_dp[1] += scrx;
8145 // midi_dp[2] += scry;
8146 // pan_dp[1] += scrx;
8147 // pan_dp[2] += scry;
8148 // emus_dp[1] += scrx;
8149 // emus_dp[2] += scry;
8150 // buf_dp[1] += scrx;
8151 // buf_dp[2] += scry;
8152 // sfx_dp[1] += scrx;
8153 // sfx_dp[2] += scry;
8154 114 }
8155
8156 /*****************************/
8157 /**** Custom Sound System ****/
8158 /*****************************/
8159
8160 114 INLINE int32_t mixvol(int32_t v1,int32_t v2)
8161 {
8162
2/4
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 114 times.
✗ Branch 3 not taken.
114 return (zc_min(v1,255)*zc_min(v2,255)) >> 8;
8163 }
8164
8165 // Run an NSF, or a MIDI if the NSF is missing somehow.
8166 149 bool try_zcmusic(char *filename, int32_t track, int32_t midi, int32_t fadeoutframes)
8167 {
8168 149 ZCMUSIC *newzcmusic = zcmusic_load_for_quest(filename, qstpath);
8169
8170 // Found it
8171
2/2
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 79 times.
149 if(newzcmusic!=NULL)
8172 {
8173 70 newzcmusic->fadevolume = 10000;
8174 70 newzcmusic->fadeoutframes = fadeoutframes;
8175
8176 70 zcmixer->newtrack = newzcmusic;
8177
8178 70 zcmusic_stop(zcmusic);
8179 70 zcmusic_unload_file(zcmusic);
8180 70 zc_stop_midi();
8181
8182 70 zcmusic=newzcmusic;
8183 70 int32_t temp_volume = emusic_volume;
8184
1/2
✓ Branch 0 taken 70 times.
✗ Branch 1 not taken.
70 if (!get_qr(qr_OLD_SCRIPT_VOLUME))
8185 temp_volume = (emusic_volume * FFCore.usr_music_volume) / 10000 / 100;
8186 70 temp_volume = (temp_volume * zcmusic->fadevolume) / 10000;
8187 70 zcmusic_play(zcmusic, temp_volume);
8188
8189
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70 times.
70 if(track>0)
8190 70 zcmusic_change_track(zcmusic,track);
8191
8192 70 return true;
8193 }
8194
8195 // Not found, play MIDI - unless this was called by a script (yay, magic numbers)
8196
1/2
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
79 else if(midi>-1000)
8197 jukebox(midi);
8198
8199 79 return false;
8200 149 }
8201
8202 bool try_zcmusic_ex(char *filename, int32_t track, int32_t midi)
8203 {
8204 ZCMUSIC *newzcmusic = zcmusic_load_for_quest(filename, qstpath);
8205 // Found it
8206 if(newzcmusic!=NULL)
8207 {
8208 zcmusic_stop(zcmusic);
8209 zcmusic_unload_file(zcmusic);
8210 zc_stop_midi();
8211
8212 zcmusic=newzcmusic;
8213 zcmusic_play(zcmusic, emusic_volume);
8214
8215 if(track>0)
8216 zcmusic_change_track(zcmusic,track);
8217
8218 return true;
8219 }
8220
8221 // Not found, play MIDI - unless this was called by a script (yay, magic numbers)
8222 else if(midi>-1000)
8223 jukebox(midi);
8224
8225 return false;
8226 }
8227
8228 int32_t get_zcmusicpos()
8229 {
8230 int32_t debugtracething = zcmusic_get_curpos(zcmusic);
8231 return debugtracething;
8232 return 0;
8233 }
8234
8235 void set_zcmusicpos(int32_t position)
8236 {
8237 zcmusic_set_curpos(zcmusic, position);
8238 }
8239
8240 void set_zcmusicspeed(int32_t speed)
8241 {
8242 zcmusic_set_speed(zcmusic, speed);
8243 }
8244
8245 int32_t get_zcmusiclen()
8246 {
8247 return zcmusic_get_length(zcmusic);
8248 }
8249
8250 void set_zcmusicloop(double start, double end)
8251 {
8252 zcmusic_set_loop(zcmusic, start, end);
8253 }
8254
8255 63871 void jukebox(int32_t index,int32_t loop)
8256 {
8257
1/2
✓ Branch 0 taken 63871 times.
✗ Branch 1 not taken.
63871 if (is_headless())
8258 63871 return;
8259
8260 music_stop();
8261
8262 if(index<0) index=MAXMIDIS-1;
8263
8264 if(index>=MAXMIDIS) index=0;
8265
8266 music_stop();
8267
8268 // Allegro's DIGMID driver (the one normally used on on Linux) gets
8269 // stuck notes when a song stops. This fixes it.
8270 if(strcmp(midi_driver->name, "DIGMID")==0)
8271 zc_set_volume(0, 0);
8272
8273 zc_set_volume(-1, mixvol(tunes[index].volume, midi_volume >>1));
8274 zc_play_midi((MIDI*)tunes[index].data,loop);
8275
8276 if(tunes[index].start>0)
8277 zc_midi_seek(tunes[index].start);
8278
8279 midi_loop_start = tunes[index].loop_start;
8280 midi_loop_end = tunes[index].loop_end;
8281
8282 currmidi=index;
8283 master_volume(digi_volume, midi_volume);
8284 //midi_paused=false;
8285 63871 }
8286
8287 63871 void jukebox(int32_t index)
8288 {
8289
1/2
✓ Branch 0 taken 63871 times.
✗ Branch 1 not taken.
63871 if(index<0) index=MAXMIDIS-1;
8290
8291
1/2
✓ Branch 0 taken 63871 times.
✗ Branch 1 not taken.
63871 if(index>=MAXMIDIS) index=0;
8292
8293 // do nothing if it's already playing
8294
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 63871 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
63871 if(index==currmidi && midi_pos>=0)
8295 {
8296 return;
8297 }
8298
8299 63871 jukebox(index,tunes[index].loop);
8300 63871 }
8301
8302 16 void play_DmapMusic()
8303 {
8304
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if (is_headless())
8305 16 return;
8306
8307 static char tfile[2048];
8308 static int32_t ttrack=0;
8309 bool domidi=false;
8310
8311 int32_t fadeoutframes = 0;
8312 if (zcmusic != NULL)
8313 fadeoutframes = zcmusic->fadeoutframes;
8314
8315 if(DMaps[currdmap].tmusic[0]!=0)
8316 {
8317 if(zcmusic==NULL ||
8318 strcmp(zcmusic->filename,DMaps[currdmap].tmusic)!=0 ||
8319 (zcmusic->type==ZCMF_GME && zcmusic->track != DMaps[currdmap].tmusictrack))
8320 {
8321 if (DMaps[currdmap].tmusic_xfade_in > 0 || fadeoutframes > 0)
8322 {
8323 if (FFCore.play_enh_music_crossfade(DMaps[currdmap].tmusic, DMaps[currdmap].tmusictrack, DMaps[currdmap].tmusic_xfade_in, fadeoutframes))
8324 {
8325 if (zcmusic != NULL)
8326 {
8327 zcmusic->fadeoutframes = DMaps[currdmap].tmusic_xfade_out;
8328 zcmusic_set_loop(zcmusic, double(DMaps[currdmap].tmusic_loop_start / 10000.0), double(DMaps[currdmap].tmusic_loop_end / 10000.0));
8329 }
8330 }
8331 }
8332 else
8333 {
8334 if (zcmusic != NULL)
8335 {
8336 zcmusic_stop(zcmusic);
8337 zcmusic_unload_file(zcmusic);
8338 zcmusic = NULL;
8339 zcmixer->newtrack = NULL;
8340 }
8341
8342 zcmusic = zcmusic_load_for_quest(DMaps[currdmap].tmusic, qstpath);
8343 zcmixer->newtrack = zcmusic;
8344
8345 if (zcmusic != NULL)
8346 {
8347 zc_stop_midi();
8348 strcpy(tfile, DMaps[currdmap].tmusic);
8349 zcmusic_play(zcmusic, emusic_volume);
8350 int32_t temptracks = 0;
8351 temptracks = zcmusic_get_tracks(zcmusic);
8352 temptracks = (temptracks < 2) ? 1 : temptracks;
8353 ttrack = vbound(DMaps[currdmap].tmusictrack, 0, temptracks - 1);
8354 zcmusic_change_track(zcmusic, ttrack);
8355 zcmusic_set_loop(zcmusic, double(DMaps[currdmap].tmusic_loop_start / 10000.0), double(DMaps[currdmap].tmusic_loop_end / 10000.0));
8356 }
8357 else
8358 {
8359 tfile[0] = 0;
8360 domidi = true;
8361 }
8362 }
8363 }
8364 }
8365 else
8366 {
8367 if (DMaps[currdmap].midi == 0 && fadeoutframes > 0 && zcmusic != NULL && strcmp(zcmusic->filename, DMaps[currdmap].tmusic) != 0)
8368 {
8369 FFCore.play_enh_music_crossfade(NULL, DMaps[currdmap].tmusictrack, DMaps[currdmap].tmusic_xfade_in, fadeoutframes);
8370 }
8371 else
8372 {
8373 domidi = true;
8374 }
8375 }
8376
8377 if(domidi)
8378 {
8379 int32_t m=DMaps[currdmap].midi;
8380
8381 switch(m)
8382 {
8383 case 1:
8384 jukebox(ZC_MIDI_OVERWORLD);
8385 break;
8386
8387 case 2:
8388 jukebox(ZC_MIDI_DUNGEON);
8389 break;
8390
8391 case 3:
8392 jukebox(ZC_MIDI_LEVEL9);
8393 break;
8394
8395 default:
8396 if(m>=4 && m<4+MAXCUSTOMMIDIS)
8397 jukebox(m+MIDIOFFSET_DMAP);
8398 else
8399 music_stop();
8400 }
8401 }
8402 16 }
8403
8404 15752 void playLevelMusic()
8405 {
8406
1/2
✓ Branch 0 taken 15752 times.
✗ Branch 1 not taken.
15752 if (is_headless())
8407 15752 return;
8408
8409 int32_t m=tmpscr->screen_midi;
8410
8411 switch(m)
8412 {
8413 case -2:
8414 music_stop();
8415 break;
8416
8417 case -1:
8418 play_DmapMusic();
8419 break;
8420
8421 case 1:
8422 jukebox(ZC_MIDI_OVERWORLD);
8423 break;
8424
8425 case 2:
8426 jukebox(ZC_MIDI_DUNGEON);
8427 break;
8428
8429 case 3:
8430 jukebox(ZC_MIDI_LEVEL9);
8431 break;
8432
8433 default:
8434 if(m>=4 && m<4+MAXCUSTOMMIDIS)
8435 jukebox(m+MIDIOFFSET_MAPSCR);
8436 else
8437 music_stop();
8438 }
8439 15752 }
8440
8441 114 void master_volume(int32_t dv,int32_t mv)
8442 {
8443
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
✓ Branch 2 taken 114 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 114 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 114 times.
✗ Branch 7 not taken.
114 if(dv>=0) digi_volume=zc_max(zc_min(dv,255),0);
8444
8445
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
✓ Branch 2 taken 114 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 114 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 114 times.
✗ Branch 7 not taken.
114 if(mv>=0) midi_volume=zc_max(zc_min(mv,255),0);
8446
8447
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
✓ Branch 2 taken 114 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 114 times.
114 int32_t i = zc_min(zc_max(currmidi,0),MAXMIDIS-1);
8448 114 int32_t temp_vol = midi_volume;
8449
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if (!get_qr(qr_OLD_SCRIPT_VOLUME))
8450 114 temp_vol = (midi_volume * FFCore.usr_music_volume) / 10000 / 100;
8451 114 zc_set_volume(digi_volume,mixvol(tunes[i].volume, temp_vol));
8452 114 }
8453
8454 /*****************/
8455 /***** SFX *****/
8456 /*****************/
8457
8458 // array of voices, one for each sfx sample in the data file
8459 // 0+ = voice #
8460 // -1 = voice not allocated
8461 114 void Z_init_sound()
8462 {
8463
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 114 times.
29298 for(int32_t i=0; i<WAV_COUNT; i++)
8464 29184 sfx_voice[i]=-1;
8465
8466
2/2
✓ Branch 0 taken 798 times.
✓ Branch 1 taken 114 times.
912 for(int32_t i=0; i<ZC_MIDI_COUNT; i++)
8467 798 tunes[i].data = (MIDI*)mididata[i].dat;
8468
8469
2/2
✓ Branch 0 taken 28728 times.
✓ Branch 1 taken 114 times.
28842 for(int32_t j=0; j<MAXCUSTOMMIDIS; j++)
8470 28728 tunes[ZC_MIDI_COUNT+j].data=NULL;
8471
8472 114 master_volume(digi_volume,midi_volume);
8473 114 }
8474
8475 // returns number of voices currently allocated
8476 int32_t sfx_count()
8477 {
8478 int32_t c=0;
8479
8480 for(int32_t i=0; i<WAV_COUNT; i++)
8481 if(sfx_voice[i]!=-1)
8482 ++c;
8483
8484 return c;
8485 }
8486
8487 // clean up finished samples
8488 9216620 void sfx_cleanup()
8489 {
8490
2/2
✓ Branch 0 taken 2359454720 times.
✓ Branch 1 taken 9216620 times.
2368671340 for(int32_t i=0; i<WAV_COUNT; i++)
8491
3/4
✓ Branch 0 taken 618867 times.
✓ Branch 1 taken 2358835853 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 618867 times.
2360073587 if(sfx_voice[i]!=-1 && voice_get_position(sfx_voice[i])<0)
8492 {
8493 618867 deallocate_voice(sfx_voice[i]);
8494 618867 sfx_voice[i]=-1;
8495 618867 }
8496 9216620 }
8497
8498 // allocates a voice for the sample "wav_index" (index into zelda.dat)
8499 // if a voice is already allocated (and/or playing), then it just returns true
8500 // Returns true: voice is allocated
8501 // false: unsuccessful
8502 963284 bool sfx_init(int32_t index)
8503 {
8504 // check index
8505
3/4
✓ Branch 0 taken 720895 times.
✓ Branch 1 taken 242389 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 720895 times.
963284 if(index<=0 || index>=WAV_COUNT)
8506 242389 return false;
8507
8508
2/2
✓ Branch 0 taken 102011 times.
✓ Branch 1 taken 618884 times.
720895 if(sfx_voice[index]==-1)
8509 {
8510
2/2
✓ Branch 0 taken 209876 times.
✓ Branch 1 taken 409008 times.
618884 if(sfxdat)
8511 {
8512
1/2
✓ Branch 0 taken 209876 times.
✗ Branch 1 not taken.
209876 if(index<Z35)
8513 {
8514 209876 sfx_voice[index]=allocate_voice((SAMPLE*)sfxdata[index].dat);
8515 209876 }
8516 else
8517 {
8518 sfx_voice[index]=allocate_voice((SAMPLE*)sfxdata[Z35].dat);
8519 }
8520 209876 }
8521 else
8522 {
8523 409008 sfx_voice[index]=allocate_voice(&customsfxdata[index]);
8524 }
8525
8526 618884 int32_t temp_volume = sfx_volume;
8527
1/2
✓ Branch 0 taken 618884 times.
✗ Branch 1 not taken.
618884 if (!get_qr(qr_OLD_SCRIPT_VOLUME))
8528 temp_volume = (sfx_volume * FFCore.usr_sfx_volume) / 10000 / 100;
8529 618884 voice_set_volume(sfx_voice[index], temp_volume);
8530 618884 }
8531
8532 720895 return sfx_voice[index] != -1;
8533 963284 }
8534
8535 int32_t sfx_get_default_freq(int32_t index)
8536 {
8537 if (sfxdat)
8538 {
8539 if (index < Z35)
8540 {
8541 return ((SAMPLE*)sfxdata[index].dat)->freq;
8542 }
8543 else
8544 {
8545 return ((SAMPLE*)sfxdata[Z35].dat)->freq;
8546 }
8547 }
8548 else
8549 {
8550 return customsfxdata[index].freq;
8551 }
8552 }
8553
8554 int32_t sfx_get_length(int32_t index)
8555 {
8556 if (sfxdat)
8557 {
8558 if (index < Z35)
8559 {
8560 return int32_t(((SAMPLE*)sfxdata[index].dat)->len);
8561 }
8562 else
8563 {
8564 return int32_t(((SAMPLE*)sfxdata[Z35].dat)->len);
8565 }
8566 }
8567 else
8568 {
8569 return int32_t(customsfxdata[index].len);
8570 }
8571 }
8572
8573 // plays an sfx sample
8574 963284 void sfx(int32_t index,int32_t pan,bool loop, bool restart, int32_t vol, int32_t freq)
8575 {
8576
2/2
✓ Branch 0 taken 720895 times.
✓ Branch 1 taken 242389 times.
963284 if(!sfx_init(index))
8577 242389 return;
8578
1/2
✓ Branch 0 taken 720895 times.
✗ Branch 1 not taken.
720895 if (!is_headless())
8579 {
8580 voice_set_playmode(sfx_voice[index], loop ? PLAYMODE_LOOP : PLAYMODE_PLAY);
8581 voice_set_pan(sfx_voice[index], pan);
8582
8583 // Only used by ZScript currently
8584 if (freq <= -1)
8585 {
8586 freq = sfx_get_default_freq(index);
8587 }
8588 voice_set_frequency(sfx_voice[index], freq);
8589
8590 // Only used by ZScript currently
8591 int32_t temp_volume = (sfx_volume * vol) / 10000 / 100;
8592 if (!get_qr(qr_OLD_SCRIPT_VOLUME))
8593 temp_volume = (temp_volume * FFCore.usr_sfx_volume) / 10000 / 100;
8594 voice_set_volume(sfx_voice[index], temp_volume);
8595
8596 int32_t pos = voice_get_position(sfx_voice[index]);
8597
8598 if (restart) voice_set_position(sfx_voice[index], 0);
8599
8600 if (pos <= 0)
8601 voice_start(sfx_voice[index]);
8602 }
8603
8604
3/4
✓ Branch 0 taken 397878 times.
✓ Branch 1 taken 323017 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 397878 times.
720895 if (restart && replay_is_debug())
8605
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 397878 times.
397878 replay_step_comment(fmt::format("sfx {}", sfx_string[index]));
8606 963284 }
8607
8608 // true if sfx is allocated
8609 67536 bool sfx_allocated(int32_t index)
8610 {
8611
3/4
✓ Branch 0 taken 9407 times.
✓ Branch 1 taken 58129 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9407 times.
67536 return (index>0 && index<WAV_COUNT && sfx_voice[index]!=-1);
8612 }
8613
8614 // start it (in loop mode) if it's not already playing,
8615 // otherwise adjust it to play in loop mode -DD
8616 178221 void cont_sfx(int32_t index)
8617 {
8618
1/2
✓ Branch 0 taken 178221 times.
✗ Branch 1 not taken.
178221 if (is_headless())
8619 178221 return;
8620
8621 if(!sfx_init(index))
8622 {
8623 return;
8624 }
8625
8626 if(voice_get_position(sfx_voice[index])<=0)
8627 {
8628 voice_set_position(sfx_voice[index],0);
8629 voice_set_playmode(sfx_voice[index],PLAYMODE_LOOP);
8630 voice_start(sfx_voice[index]);
8631 }
8632 else
8633 {
8634 adjust_sfx(index, 128, true);
8635 }
8636 178221 }
8637
8638 // adjust parameters while playing
8639 4075 void adjust_sfx(int32_t index,int32_t pan,bool loop)
8640 {
8641
4/6
✓ Branch 0 taken 2315 times.
✓ Branch 1 taken 1760 times.
✓ Branch 2 taken 2315 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2315 times.
4075 if(index<=0 || index>=WAV_COUNT || sfx_voice[index]==-1)
8642 4075 return;
8643
8644 voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY);
8645 voice_set_pan(sfx_voice[index],pan);
8646 4075 }
8647
8648 // pauses a voice
8649 1725 void pause_sfx(int32_t index)
8650 {
8651
3/6
✓ Branch 0 taken 1725 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1725 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1725 times.
1725 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
8652 voice_stop(sfx_voice[index]);
8653 1725 }
8654
8655 // resumes a voice
8656 747 void resume_sfx(int32_t index)
8657 {
8658
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 747 times.
747 if (is_headless())
8659 747 return;
8660
8661 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
8662 voice_start(sfx_voice[index]);
8663 747 }
8664
8665 // pauses all active voices
8666 448 void pause_all_sfx()
8667 {
8668
2/2
✓ Branch 0 taken 114688 times.
✓ Branch 1 taken 448 times.
115136 for(int32_t i=0; i<WAV_COUNT; i++)
8669
2/2
✓ Branch 0 taken 114687 times.
✓ Branch 1 taken 1 times.
114689 if(sfx_voice[i]!=-1)
8670 1 voice_stop(sfx_voice[i]);
8671 448 }
8672
8673 // resumes all paused voices
8674 434 void resume_all_sfx()
8675 {
8676
2/2
✓ Branch 0 taken 111104 times.
✓ Branch 1 taken 434 times.
111538 for(int32_t i=0; i<WAV_COUNT; i++)
8677
1/2
✓ Branch 0 taken 111104 times.
✗ Branch 1 not taken.
111104 if(sfx_voice[i]!=-1)
8678 voice_start(sfx_voice[i]);
8679 434 }
8680
8681 // stops an sfx and deallocates the voice
8682 7333904 void stop_sfx(int32_t index)
8683 {
8684
3/4
✓ Branch 0 taken 6180795 times.
✓ Branch 1 taken 1153109 times.
✓ Branch 2 taken 6180795 times.
✗ Branch 3 not taken.
7333904 if(index<=0 || index>=WAV_COUNT)
8685 1153109 return;
8686
8687
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 6180784 times.
6180795 if(sfx_voice[index]!=-1)
8688 {
8689 11 deallocate_voice(sfx_voice[index]);
8690 11 sfx_voice[index]=-1;
8691 11 }
8692 7333904 }
8693
8694 // Stops SFX played by Hero's item of the given family
8695 128638 void stop_item_sfx(int32_t family)
8696 {
8697 128638 int32_t id=current_item_id(family);
8698
8699
2/2
✓ Branch 0 taken 128083 times.
✓ Branch 1 taken 555 times.
128638 if(id<0)
8700 128083 return;
8701
8702 555 stop_sfx(itemsbuf[id].usesound);
8703 128638 }
8704
8705 3220 void kill_sfx()
8706 {
8707
2/2
✓ Branch 0 taken 824320 times.
✓ Branch 1 taken 3220 times.
827540 for(int32_t i=0; i<WAV_COUNT; i++)
8708
2/2
✓ Branch 0 taken 824314 times.
✓ Branch 1 taken 6 times.
824326 if(sfx_voice[i]!=-1)
8709 {
8710 6 deallocate_voice(sfx_voice[i]);
8711 6 sfx_voice[i]=-1;
8712 6 }
8713 3220 }
8714
8715 659526 int32_t pan(int32_t x)
8716 {
8717
1/4
✓ Branch 0 taken 659526 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
659526 switch(pan_style)
8718 {
8719 case 0:
8720 return 128;
8721
8722 case 1:
8723 659526 return vbound((x>>1)+68,0,255);
8724
8725 case 2:
8726 return vbound(((x*3)>>2)+36,0,255);
8727 }
8728
8729 return vbound(x,0,255);
8730 659526 }
8731
8732 /*******************************/
8733 /******* Input Handlers ********/
8734 /*******************************/
8735
8736 25091655 bool joybtn(int32_t b)
8737 {
8738
1/2
✓ Branch 0 taken 25091655 times.
✗ Branch 1 not taken.
25091655 if(b == 0)
8739 return false;
8740
1/2
✓ Branch 0 taken 25091655 times.
✗ Branch 1 not taken.
25091655 if (b-1 >= joy[joystick_index].num_buttons)
8741 25091655 return false;
8742
8743 return joy[joystick_index].button[b-1].b !=0;
8744 25091655 }
8745
8746 const char* joybtn_name(int32_t b)
8747 {
8748 if (b <= 0 || b > joy[joystick_index].num_buttons)
8749 return "";
8750
8751 return joy[joystick_index].button[b-1].name;
8752 }
8753
8754 int32_t next_press_key();
8755
8756 int32_t next_press_btn()
8757 {
8758 clear_keybuf();
8759 /*bool b[joy[joystick_index].num_buttons+1];
8760
8761 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
8762 b[i]=joybtn(i);*/
8763
8764 //first, we need to wait until they're pressing no buttons
8765 for(;;)
8766 {
8767 if(keypressed())
8768 {
8769 switch(readkey()>>8)
8770 {
8771 case KEY_ESC:
8772 return -1;
8773
8774 case KEY_SPACE:
8775 return 0;
8776 }
8777 }
8778
8779 poll_joystick();
8780 bool done = true;
8781
8782 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
8783 {
8784 if(joybtn(i)) done = false;
8785 }
8786
8787 if(done) break;
8788 rest(1);
8789 }
8790
8791 //now, we need to wait for them to press any button
8792 for(;;)
8793 {
8794 if(keypressed())
8795 {
8796 switch(readkey()>>8)
8797 {
8798 case KEY_ESC:
8799 return -1;
8800
8801 case KEY_SPACE:
8802 return 0;
8803 }
8804 }
8805
8806 poll_joystick();
8807
8808 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
8809 {
8810 if(joybtn(i)) return i;
8811 }
8812 rest(1);
8813 }
8814 }
8815
8816 1204128 static bool rButton(bool &btn, bool &flag, bool rawbtn)
8817 {
8818
2/2
✓ Branch 0 taken 1199785 times.
✓ Branch 1 taken 4343 times.
1204128 bool ret = btn && !flag;
8819 1204128 flag = rawbtn;
8820
8821 1204128 return ret;
8822 }
8823 190771694 static bool rButton(bool &btn, bool &flag)
8824 {
8825
2/2
✓ Branch 0 taken 183928991 times.
✓ Branch 1 taken 6842703 times.
190771694 bool ret = btn && !flag;
8826 190771694 flag = btn;
8827
8828 190771694 return ret;
8829 }
8830 2888422 static bool rButtonPeek(bool btn, bool flag)
8831 {
8832
2/2
✓ Branch 0 taken 2685421 times.
✓ Branch 1 taken 203001 times.
2888422 if(!btn)
8833 {
8834 2685421 return false;
8835 }
8836
2/2
✓ Branch 0 taken 17917 times.
✓ Branch 1 taken 185084 times.
203001 else if(!flag)
8837 {
8838 17917 return true;
8839 }
8840
8841 185084 return false;
8842 2888422 }
8843
8844 // Updated only by keyboard/gamepad.
8845 // If in replay mode, this is set directly by the replay system.
8846 // This should never be read from directly - use control_state instead.
8847 bool raw_control_state[ZC_CONTROL_STATES];
8848
8849 // Every call to load_control_state (pretty much every frame) resets this to be equal to raw_control_state.
8850 // This state can drift from raw_control_state if button states are "eaten" or overriden by a script. But that only
8851 // lasts until the next call to load_control_state.
8852 bool control_state[ZC_CONTROL_STATES];
8853 bool disable_control[ZC_CONTROL_STATES];
8854 bool drunk_toggle_state[11];
8855 bool disabledKeys[127];
8856 bool KeyInput[127];
8857 bool KeyPress[127];
8858
8859 bool key_current_frame[127];
8860 bool key_previous_frame[127];
8861
8862 static bool key_system[127];
8863 static bool key_system_previous[127];
8864 static bool key_system_press[127];
8865
8866 bool button_press[ZC_CONTROL_STATES];
8867 bool button_hold[ZC_CONTROL_STATES];
8868
8869 #define STICK_1_X joy[joystick_index].stick[js_stick_1_x_stick].axis[js_stick_1_x_axis]
8870 #define STICK_1_Y joy[joystick_index].stick[js_stick_1_y_stick].axis[js_stick_1_y_axis]
8871 #define STICK_2_X joy[joystick_index].stick[js_stick_2_x_stick].axis[js_stick_2_x_axis]
8872 #define STICK_2_Y joy[joystick_index].stick[js_stick_2_y_stick].axis[js_stick_2_y_axis]
8873 #define STICK_PRECISION 56 //define your own sensitivity
8874
8875 7799523 void load_control_state()
8876 {
8877 7799523 load_control_called_this_frame = true;
8878
8879
2/2
✓ Branch 0 taken 4832992 times.
✓ Branch 1 taken 2966531 times.
7799523 if (replay_version_check(8, 11))
8880 {
8881
2/2
✓ Branch 0 taken 53397558 times.
✓ Branch 1 taken 2966531 times.
56364089 for (int i = 0; i < ZC_CONTROL_STATES; i++)
8882 53397558 down_control_states[i] = raw_control_state[i];
8883 2966531 }
8884
8885
1/2
✓ Branch 0 taken 7799523 times.
✗ Branch 1 not taken.
7799523 if (!replay_is_replaying())
8886 {
8887 raw_control_state[0]=zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset < -STICK_PRECISION : joybtn(DUbtn));
8888 raw_control_state[1]=zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn));
8889 raw_control_state[2]=zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn));
8890 raw_control_state[3]=zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn));
8891 raw_control_state[4]=zc_getrawkey(Akey, true)||joybtn(Abtn);
8892 raw_control_state[5]=zc_getrawkey(Bkey, true)||joybtn(Bbtn);
8893 raw_control_state[6]=zc_getrawkey(Skey, true)||joybtn(Sbtn);
8894 raw_control_state[7]=zc_getrawkey(Lkey, true)||joybtn(Lbtn);
8895 raw_control_state[8]=zc_getrawkey(Rkey, true)||joybtn(Rbtn);
8896 raw_control_state[9]=zc_getrawkey(Pkey, true)||joybtn(Pbtn);
8897 raw_control_state[10]=zc_getrawkey(Exkey1, true)||joybtn(Exbtn1);
8898 raw_control_state[11]=zc_getrawkey(Exkey2, true)||joybtn(Exbtn2);
8899 raw_control_state[12]=zc_getrawkey(Exkey3, true)||joybtn(Exbtn3);
8900 raw_control_state[13]=zc_getrawkey(Exkey4, true)||joybtn(Exbtn4);
8901
8902 if(num_joysticks != 0)
8903 {
8904 raw_control_state[14] = STICK_2_Y.pos - js_stick_2_y_offset < -STICK_PRECISION;
8905 raw_control_state[15] = STICK_2_Y.pos - js_stick_2_y_offset > STICK_PRECISION;
8906 raw_control_state[16] = STICK_2_X.pos - js_stick_2_x_offset < -STICK_PRECISION;
8907 raw_control_state[17] = STICK_2_X.pos - js_stick_2_x_offset > STICK_PRECISION;
8908 // zprint2("Detected %d joysticks... %d%d%d%d\n", num_joysticks, raw_control_state[14]?1:0, raw_control_state[15]?1:0, raw_control_state[16]?1:0, raw_control_state[17]?1:0);
8909 }
8910 else
8911 {
8912 raw_control_state[14] = false;
8913 raw_control_state[15] = false;
8914 raw_control_state[16] = false;
8915 raw_control_state[17] = false;
8916 // zprint2("Detected 0 joysticks... clearing inputaxis values.\n");
8917 }
8918 }
8919
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 7799520 times.
7799523 if (replay_is_active())
8920 {
8921
2/2
✓ Branch 0 taken 1015215 times.
✓ Branch 1 taken 6784305 times.
7799520 if (replay_get_version() < 3)
8922 1015215 replay_poll();
8923
3/4
✓ Branch 0 taken 6784305 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5022930 times.
✓ Branch 3 taken 1761375 times.
6784305 else if (replay_is_replaying() && replay_get_version() < 6)
8924 1761375 replay_peek_input();
8925
3/4
✓ Branch 0 taken 5022930 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2056399 times.
✓ Branch 3 taken 2966531 times.
5022930 else if (replay_is_replaying() && replay_version_check(8, 11))
8926 2966531 replay_peek_input();
8927
2/2
✓ Branch 0 taken 6696212 times.
✓ Branch 1 taken 1103308 times.
7799520 if (replay_get_version() == 8)
8928 1103308 update_keys();
8929 7799520 }
8930
8931 // Some test replay files were made before a serious input bug was fixed, so instead
8932 // of re-doing them or tossing them out, just check for that zplay version.
8933
3/4
✓ Branch 0 taken 7799517 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 121900 times.
✓ Branch 3 taken 7677617 times.
7799523 bool botched_input = replay_is_active() && replay_get_version() != 1 && replay_get_version() < 8;
8934
2/2
✓ Branch 0 taken 140391306 times.
✓ Branch 1 taken 7799517 times.
148190823 for (int i = 0; i < ZC_CONTROL_STATES; i++)
8935 {
8936 140391306 control_state[i] = raw_control_state[i];
8937
4/4
✓ Branch 0 taken 49487310 times.
✓ Branch 1 taken 90903996 times.
✓ Branch 2 taken 2410168 times.
✓ Branch 3 taken 47077142 times.
140391306 if (botched_input && !control_state[i])
8938 47077142 down_control_states[i] = false;
8939 140391306 }
8940 7799517 bool did_bad_cutscene_btn = false;
8941
2/2
✓ Branch 0 taken 7799517 times.
✓ Branch 1 taken 140391306 times.
148190823 for(int q = 0; q < 18; ++q)
8942
3/4
✓ Branch 0 taken 6462661 times.
✓ Branch 1 taken 133928645 times.
✓ Branch 2 taken 6462661 times.
✗ Branch 3 not taken.
140391306 if(control_state[q] && !active_cutscene.can_button(q))
8943 {
8944 control_state[q] = false;
8945 did_bad_cutscene_btn = true;
8946 }
8947
1/2
✓ Branch 0 taken 7799517 times.
✗ Branch 1 not taken.
7799517 if(did_bad_cutscene_btn)
8948 active_cutscene.error();
8949
8950 7799517 button_press[0]=rButton(control_state[0],button_hold[0]);
8951 7799517 button_press[1]=rButton(control_state[1],button_hold[1]);
8952 7799517 button_press[2]=rButton(control_state[2],button_hold[2]);
8953 7799517 button_press[3]=rButton(control_state[3],button_hold[3]);
8954 7799517 button_press[4]=rButton(control_state[4],button_hold[4]);
8955 7799517 button_press[5]=rButton(control_state[5],button_hold[5]);
8956 7799517 button_press[6]=rButton(control_state[6],button_hold[6]);
8957 7799517 button_press[7]=rButton(control_state[7],button_hold[7]);
8958 7799517 button_press[8]=rButton(control_state[8],button_hold[8]);
8959 7799517 button_press[9]=rButton(control_state[9],button_hold[9]);
8960 7799517 button_press[10]=rButton(control_state[10],button_hold[10]);
8961 7799517 button_press[11]=rButton(control_state[11],button_hold[11]);
8962 7799517 button_press[12]=rButton(control_state[12],button_hold[12]);
8963 7799517 button_press[13]=rButton(control_state[13],button_hold[13]);
8964 7799517 button_press[14]=rButton(control_state[14],button_hold[14]);
8965 7799517 button_press[15]=rButton(control_state[15],button_hold[15]);
8966 7799517 button_press[16]=rButton(control_state[16],button_hold[16]);
8967 7799517 button_press[17]=rButton(control_state[17],button_hold[17]);
8968 7799517 }
8969
8970 // Returns true if any game key is pressed. This is needed because keypressed()
8971 // doesn't detect modifier keys and control_state[] can be modified by scripts.
8972 40244872 bool zc_key_pressed()
8973 //may also need to use zc_getrawkey
8974 {
8975
7/10
✓ Branch 0 taken 32593390 times.
✓ Branch 1 taken 7651482 times.
✓ Branch 2 taken 7651482 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7651482 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6395266 times.
✓ Branch 7 taken 6395266 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 2461556 times.
42706428 if((zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset< -STICK_PRECISION : joybtn(DUbtn))) ||
8976
4/6
✓ Branch 0 taken 6395266 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6395266 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4843509 times.
✓ Branch 5 taken 4843509 times.
6395266 (zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn))) ||
8977
4/6
✓ Branch 0 taken 4843509 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4843509 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3142850 times.
✓ Branch 5 taken 3142850 times.
4843509 (zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn))) ||
8978
4/6
✓ Branch 0 taken 3142850 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3142850 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2732011 times.
✓ Branch 5 taken 2732011 times.
3142850 (zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn))) ||
8979
1/2
✓ Branch 0 taken 2732011 times.
✗ Branch 1 not taken.
2732011 (zc_getrawkey(Akey, true)||joybtn(Abtn)) ||
8980
3/4
✓ Branch 0 taken 2612604 times.
✓ Branch 1 taken 119407 times.
✓ Branch 2 taken 2612604 times.
✗ Branch 3 not taken.
2732011 (zc_getrawkey(Bkey, true)||joybtn(Bbtn)) ||
8981
3/4
✓ Branch 0 taken 2493715 times.
✓ Branch 1 taken 118889 times.
✓ Branch 2 taken 2493715 times.
✗ Branch 3 not taken.
2612604 (zc_getrawkey(Skey, true)||joybtn(Sbtn)) ||
8982
3/4
✓ Branch 0 taken 2478570 times.
✓ Branch 1 taken 15145 times.
✓ Branch 2 taken 2478570 times.
✗ Branch 3 not taken.
2493715 (zc_getrawkey(Lkey, true)||joybtn(Lbtn)) ||
8983
3/4
✓ Branch 0 taken 2465071 times.
✓ Branch 1 taken 13499 times.
✓ Branch 2 taken 2465071 times.
✗ Branch 3 not taken.
2478570 (zc_getrawkey(Rkey, true)||joybtn(Rbtn)) ||
8984
3/4
✓ Branch 0 taken 2462581 times.
✓ Branch 1 taken 2490 times.
✓ Branch 2 taken 2462581 times.
✗ Branch 3 not taken.
2465071 (zc_getrawkey(Pkey, true)||joybtn(Pbtn)) ||
8985
3/4
✓ Branch 0 taken 2462391 times.
✓ Branch 1 taken 190 times.
✓ Branch 2 taken 2462391 times.
✗ Branch 3 not taken.
2462581 (zc_getrawkey(Exkey1, true)||joybtn(Exbtn1)) ||
8986
3/4
✓ Branch 0 taken 2461581 times.
✓ Branch 1 taken 810 times.
✓ Branch 2 taken 2461581 times.
✗ Branch 3 not taken.
2462391 (zc_getrawkey(Exkey2, true)||joybtn(Exbtn2)) ||
8987
3/4
✓ Branch 0 taken 2461575 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 2461575 times.
✗ Branch 3 not taken.
2461581 (zc_getrawkey(Exkey3, true)||joybtn(Exbtn3)) ||
8988
2/2
✓ Branch 0 taken 2461556 times.
✓ Branch 1 taken 19 times.
2461575 (zc_getrawkey(Exkey4, true)||joybtn(Exbtn4))) // Skipping joystick axes
8989 72010588 return true;
8990
8991 2461556 return false;
8992 9285364 }
8993
8994 150311175 bool getInput(int32_t btn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
8995 {
8996 150311175 bool ret = false, drunkstate = false, rawret = false;;
8997 150311175 bool* flag = &down_control_states[btn];
8998
2/7
✓ Branch 0 taken 141016474 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 9294701 times.
150311175 switch(btn)
8999 {
9000 case btnF12:
9001 ret = zc_getkey(KEY_F12, ignoreDisable);
9002 rawret = zc_getrawkey(KEY_F12, ignoreDisable);
9003 eatEntirely = false;
9004 break;
9005 case btnF11:
9006 ret = zc_getkey(KEY_F11, ignoreDisable);
9007 rawret = zc_getrawkey(KEY_F11, ignoreDisable);
9008 eatEntirely = false;
9009 break;
9010 case btnF5:
9011 ret = zc_getkey(KEY_F5, ignoreDisable);
9012 rawret = zc_getrawkey(KEY_F5, ignoreDisable);
9013 eatEntirely = false;
9014 break;
9015 case btnQ:
9016 ret = zc_getkey(KEY_Q, ignoreDisable);
9017 rawret = zc_getrawkey(KEY_Q, ignoreDisable);
9018 eatEntirely = false;
9019 break;
9020 case btnI:
9021 ret = zc_getkey(KEY_I, ignoreDisable);
9022 rawret = zc_getrawkey(KEY_I, ignoreDisable);
9023 eatEntirely = false;
9024 break;
9025 case btnM:
9026
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9294701 times.
9294701 if(FFCore.kb_typing_mode) return false;
9027 9294701 rawret = ret = zc_getrawkey(KEY_ESC, ignoreDisable);
9028 9294701 eatEntirely = false;
9029 9294701 break;
9030 default: //control_state[] index
9031
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 141016474 times.
141016474 if(FFCore.kb_typing_mode) return false;
9032
5/6
✓ Branch 0 taken 140216695 times.
✓ Branch 1 taken 799779 times.
✓ Branch 2 taken 2216458 times.
✓ Branch 3 taken 138000237 times.
✓ Branch 4 taken 2216458 times.
✗ Branch 5 not taken.
141016474 if(!ignoreDisable && get_qr(qr_FIXDRUNKINPUTS) && disable_control[btn]) drunk = false;
9033
2/2
✓ Branch 0 taken 8034012 times.
✓ Branch 1 taken 132982462 times.
141016474 else if(btn<11) drunkstate = drunk_toggle_state[btn];
9034
4/4
✓ Branch 0 taken 126851564 times.
✓ Branch 1 taken 14164910 times.
✓ Branch 2 taken 3004 times.
✓ Branch 3 taken 14161906 times.
155181384 ret = control_state[btn] && (ignoreDisable || !disable_control[btn]);
9035 141016474 rawret = raw_control_state[btn];
9036 141016474 }
9037
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 150311175 times.
150311175 assert(flag);
9038
2/2
✓ Branch 0 taken 95838237 times.
✓ Branch 1 taken 54472938 times.
150311175 if(press)
9039 {
9040
2/2
✓ Branch 0 taken 2888422 times.
✓ Branch 1 taken 51584516 times.
54472938 if(peek)
9041 2888422 ret = rButtonPeek(ret, *flag);
9042
2/2
✓ Branch 0 taken 50380388 times.
✓ Branch 1 taken 1204128 times.
51584516 else if(get_qr(qr_BROKEN_INPUT_DOWN_STATE)) ret = rButton(ret, *flag);
9043 1204128 else ret = rButton(ret, *flag, rawret);
9044 54472938 }
9045
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 150311175 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
150311175 if(eatEntirely && ret) control_state[btn] = false;
9046
3/4
✓ Branch 0 taken 112357476 times.
✓ Branch 1 taken 37953699 times.
✓ Branch 2 taken 112357476 times.
✗ Branch 3 not taken.
150311175 if(drunk && drunkstate) ret = !ret;
9047 150311175 return ret;
9048 150311175 }
9049
9050 7463994 byte getIntBtnInput(byte intbtn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
9051 {
9052 7463994 byte ret = 0;
9053
2/2
✓ Branch 0 taken 5485237 times.
✓ Branch 1 taken 1978757 times.
7463994 if(intbtn & INT_BTN_A) ret |= getInput(btnA, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_A : 0;
9054
2/2
✓ Branch 0 taken 7333180 times.
✓ Branch 1 taken 130814 times.
7463994 if(intbtn & INT_BTN_B) ret |= getInput(btnB, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_B : 0;
9055
2/2
✓ Branch 0 taken 7333305 times.
✓ Branch 1 taken 130689 times.
7463994 if(intbtn & INT_BTN_L) ret |= getInput(btnL, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_L : 0;
9056
2/2
✓ Branch 0 taken 7333305 times.
✓ Branch 1 taken 130689 times.
7463994 if(intbtn & INT_BTN_R) ret |= getInput(btnR, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_R : 0;
9057
2/2
✓ Branch 0 taken 7333305 times.
✓ Branch 1 taken 130689 times.
7463994 if(intbtn & INT_BTN_EX1) ret |= getInput(btnEx1, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX1 : 0;
9058
2/2
✓ Branch 0 taken 7333305 times.
✓ Branch 1 taken 130689 times.
7463994 if(intbtn & INT_BTN_EX2) ret |= getInput(btnEx2, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX2 : 0;
9059
2/2
✓ Branch 0 taken 7333305 times.
✓ Branch 1 taken 130689 times.
7463994 if(intbtn & INT_BTN_EX3) ret |= getInput(btnEx3, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX3 : 0;
9060
2/2
✓ Branch 0 taken 7333305 times.
✓ Branch 1 taken 130689 times.
7463994 if(intbtn & INT_BTN_EX4) ret |= getInput(btnEx4, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX4 : 0;
9061 7463994 return ret; //No early return, to make sure all button presses are eaten that should be! -Em
9062 }
9063
9064 1114 byte checkIntBtnVal(byte intbtn, byte vals)
9065 {
9066 1114 return intbtn&vals;
9067 }
9068
9069 1767610 bool Up()
9070 {
9071 1767610 return getInput(btnUp);
9072 }
9073 147138 bool Down()
9074 {
9075 147138 return getInput(btnDown);
9076 }
9077 257494 bool Left()
9078 {
9079 257494 return getInput(btnLeft);
9080 }
9081 286688 bool Right()
9082 {
9083 286688 return getInput(btnRight);
9084 }
9085 164850 bool cAbtn()
9086 {
9087 164850 return getInput(btnA);
9088 }
9089 1411781 bool cBbtn()
9090 {
9091 1411781 return getInput(btnB);
9092 }
9093 bool cSbtn()
9094 {
9095 return getInput(btnS);
9096 }
9097 68744 bool cLbtn()
9098 {
9099 68744 return getInput(btnL);
9100 }
9101 68744 bool cRbtn()
9102 {
9103 68744 return getInput(btnR);
9104 }
9105 bool cPbtn()
9106 {
9107 return getInput(btnP);
9108 }
9109 bool cEx1btn()
9110 {
9111 return getInput(btnEx1);
9112 }
9113 bool cEx2btn()
9114 {
9115 return getInput(btnEx2);
9116 }
9117 bool cEx3btn()
9118 {
9119 return getInput(btnEx3);
9120 }
9121 bool cEx4btn()
9122 {
9123 return getInput(btnEx4);
9124 }
9125 bool AxisUp()
9126 {
9127 return getInput(btnAxisUp);
9128 }
9129 bool AxisDown()
9130 {
9131 return getInput(btnAxisDown);
9132 }
9133 bool AxisLeft()
9134 {
9135 return getInput(btnAxisLeft);
9136 }
9137 bool AxisRight()
9138 {
9139 return getInput(btnAxisRight);
9140 }
9141
9142 bool cMbtn()
9143 {
9144 return getInput(btnM);
9145 }
9146 bool cF12()
9147 {
9148 return getInput(btnF12);
9149 }
9150 bool cF11()
9151 {
9152 return getInput(btnF11);
9153 }
9154 bool cF5()
9155 {
9156 return getInput(btnF5);
9157 }
9158 bool cQ()
9159 {
9160 return getInput(btnQ);
9161 }
9162 bool cI()
9163 {
9164 return getInput(btnI);
9165 }
9166
9167 130270 bool rUp()
9168 {
9169 130270 return getInput(btnUp, true);
9170 }
9171 130174 bool rDown()
9172 {
9173 130174 return getInput(btnDown, true);
9174 }
9175 130122 bool rLeft()
9176 {
9177 130122 return getInput(btnLeft, true);
9178 }
9179 129657 bool rRight()
9180 {
9181 129657 return getInput(btnRight, true);
9182 }
9183 1295 bool rAbtn()
9184 {
9185 1295 return getInput(btnA, true);
9186 }
9187 1295 bool rBbtn()
9188 {
9189 1295 return getInput(btnB, true);
9190 }
9191 7395872 bool rSbtn()
9192 {
9193 7395872 return getInput(btnS, true);
9194 }
9195 9285364 bool rMbtn()
9196 {
9197 9285364 return getInput(btnM, true);
9198 }
9199 129441 bool rLbtn()
9200 {
9201 129441 return getInput(btnL, true);
9202 }
9203 129436 bool rRbtn()
9204 {
9205 129436 return getInput(btnR, true);
9206 }
9207 7332336 bool rPbtn()
9208 {
9209 7332336 return getInput(btnP, true);
9210 }
9211 bool rEx1btn()
9212 {
9213 return getInput(btnEx1, true);
9214 }
9215 bool rEx2btn()
9216 {
9217 return getInput(btnEx2, true);
9218 }
9219 139523 bool rEx3btn()
9220 {
9221 139523 return getInput(btnEx3, true);
9222 }
9223 139523 bool rEx4btn()
9224 {
9225 139523 return getInput(btnEx4, true);
9226 }
9227 bool rAxisUp()
9228 {
9229 return getInput(btnAxisUp, true);
9230 }
9231 bool rAxisDown()
9232 {
9233 return getInput(btnAxisDown, true);
9234 }
9235 bool rAxisLeft()
9236 {
9237 return getInput(btnAxisLeft, true);
9238 }
9239 bool rAxisRight()
9240 {
9241 return getInput(btnAxisRight, true);
9242 }
9243
9244 bool rF11()
9245 {
9246 return getInput(btnF11, true);
9247 }
9248 bool rQ()
9249 {
9250 return getInput(btnQ, true);
9251 }
9252 bool rI()
9253 {
9254 return getInput(btnI, true);
9255 }
9256
9257 18224269 bool DrunkUp()
9258 {
9259 18224269 return getInput(btnUp, false, true);
9260 }
9261 16887410 bool DrunkDown()
9262 {
9263 16887410 return getInput(btnDown, false, true);
9264 }
9265 10287566 bool DrunkLeft()
9266 {
9267 10287566 return getInput(btnLeft, false, true);
9268 }
9269 8833443 bool DrunkRight()
9270 {
9271 8833443 return getInput(btnRight, false, true);
9272 }
9273 8034628 bool DrunkcAbtn()
9274 {
9275 8034628 return getInput(btnA, false, true);
9276 }
9277 8016230 bool DrunkcBbtn()
9278 {
9279 8016230 return getInput(btnB, false, true);
9280 }
9281 7263206 bool DrunkcEx1btn()
9282 {
9283 7263206 return getInput(btnEx1, false, true);
9284 }
9285 7263226 bool DrunkcEx2btn()
9286 {
9287 7263226 return getInput(btnEx2, false, true);
9288 }
9289 bool DrunkcSbtn()
9290 {
9291 return getInput(btnS, false, true);
9292 }
9293 bool DrunkcMbtn()
9294 {
9295 return getInput(btnM, false, true);
9296 }
9297 bool DrunkcLbtn()
9298 {
9299 return getInput(btnL, false, true);
9300 }
9301 bool DrunkcRbtn()
9302 {
9303 return getInput(btnR, false, true);
9304 }
9305 bool DrunkcPbtn()
9306 {
9307 return getInput(btnP, false, true);
9308 }
9309
9310 bool DrunkrUp()
9311 {
9312 return getInput(btnUp, true, true);
9313 }
9314 bool DrunkrDown()
9315 {
9316 return getInput(btnDown, true, true);
9317 }
9318 bool DrunkrLeft()
9319 {
9320 return getInput(btnLeft, true, true);
9321 }
9322 bool DrunkrRight()
9323 {
9324 return getInput(btnRight, true, true);
9325 }
9326 6081014 bool DrunkrAbtn()
9327 {
9328 6081014 return getInput(btnA, true, true);
9329 }
9330 6097835 bool DrunkrBbtn()
9331 {
9332 6097835 return getInput(btnB, true, true);
9333 }
9334 71669 bool DrunkrEx1btn()
9335 {
9336 71669 return getInput(btnEx1, true, true);
9337 }
9338 71662 bool DrunkrEx2btn()
9339 {
9340 71662 return getInput(btnEx2, true, true);
9341 }
9342 bool DrunkrEx3btn()
9343 {
9344 return getInput(btnEx3, true, true);
9345 }
9346 bool DrunkrEx4btn()
9347 {
9348 return getInput(btnEx4, true, true);
9349 }
9350 bool DrunkrSbtn()
9351 {
9352 return getInput(btnS, true, true);
9353 }
9354 bool DrunkrMbtn()
9355 {
9356 return getInput(btnM, true, true);
9357 }
9358 6688552 bool DrunkrLbtn()
9359 {
9360 6688552 return getInput(btnL, true, true);
9361 }
9362 6685077 bool DrunkrRbtn()
9363 {
9364 6685077 return getInput(btnR, true, true);
9365 }
9366 bool DrunkrPbtn()
9367 {
9368 return getInput(btnP, true, true);
9369 }
9370
9371 9337 void eat_buttons()
9372 {
9373 9337 getInput(btnA, true, false, true);
9374 9337 getInput(btnB, true, false, true);
9375 9337 getInput(btnS, true, false, true);
9376 9337 getInput(btnM, true, false, true);
9377 9337 getInput(btnL, true, false, true);
9378 9337 getInput(btnR, true, false, true);
9379 9337 getInput(btnP, true, false, true);
9380 9337 getInput(btnEx1, true, false, true);
9381 9337 getInput(btnEx2, true, false, true);
9382 9337 getInput(btnEx3, true, false, true);
9383 9337 getInput(btnEx4, true, false, true);
9384 9337 }
9385
9386 // Is true for the _first frame_ of a key press.
9387 // But! it is possible that a script manually sets the value of KeyPress,
9388 // in which case it will be restored to the "true" value based on `key_current_frame`
9389 // and `key_previous_frame` on the next frame.
9390 14 bool zc_readkey(int32_t k, bool ignoreDisable)
9391 {
9392
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(ignoreDisable) return KeyPress[k];
9393
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 switch(k)
9394 {
9395 case KEY_F7:
9396 case KEY_F8:
9397 case KEY_F9:
9398 return KeyPress[k];
9399
9400 default:
9401
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 return KeyPress[k] && !disabledKeys[k];
9402 }
9403 14 }
9404
9405 // Is true for _every frame_ a key is held down.
9406 // But! it is possible that a script manually sets the value of KeyInput,
9407 // in which case it will be restored to the "true" value based on `key_current_frame`
9408 // on the next frame.
9409 bool zc_getkey(int32_t k, bool ignoreDisable)
9410 {
9411 if(ignoreDisable) return KeyInput[k];
9412 switch(k)
9413 {
9414 case KEY_F7:
9415 case KEY_F8:
9416 case KEY_F9:
9417 return KeyInput[k];
9418
9419 default:
9420 return KeyInput[k] && !disabledKeys[k];
9421 }
9422 }
9423
9424 // Reads (and then clears) the current frame key state directly.
9425 // Scripts can also modify `key_current_frame`.
9426 303 bool zc_readrawkey(int32_t k, bool ignoreDisable)
9427 {
9428
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 301 times.
303 if(zc_getrawkey(k, ignoreDisable))
9429 {
9430 2 _key[k]=key[k]=key_current_frame[k]=0;
9431 2 return true;
9432 }
9433 301 _key[k]=key[k]=key_current_frame[k]=0;
9434 301 return false;
9435 303 }
9436
9437 // Reads the current frame key state directly.
9438 // Scripts can also modify `key_current_frame`.
9439 63243574 bool zc_getrawkey(int32_t k, bool ignoreDisable)
9440 {
9441
2/2
✓ Branch 0 taken 53958182 times.
✓ Branch 1 taken 9285392 times.
63243574 if(ignoreDisable) return key_current_frame[k];
9442
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9285392 times.
9285392 switch(k)
9443 {
9444 case KEY_F7:
9445 case KEY_F8:
9446 case KEY_F9:
9447 return key_current_frame[k];
9448
9449 default:
9450
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9285392 times.
9285392 return key_current_frame[k] && !disabledKeys[k];
9451 }
9452 63243574 }
9453
9454 // Only used for a handful of keys, like tilde and Function keys.
9455 // This state is never read within the game.
9456 // It exists so that all keyboard input still functions during replay,
9457 // without inadvertently doing things like toggling throttling if the player
9458 // presses ~
9459 9285364 bool zc_get_system_key(int32_t k)
9460 {
9461 9285364 return key_system[k];
9462 }
9463
9464 // True for the _first_ frame of a key press.
9465 83568276 bool zc_read_system_key(int32_t k)
9466 {
9467 83568276 return key_system_press[k];
9468 }
9469
9470 1179241228 bool is_system_key(int32_t k)
9471 {
9472
2/2
✓ Branch 0 taken 1095672952 times.
✓ Branch 1 taken 83568276 times.
1179241228 switch (k)
9473 {
9474 case KEY_BACKQUOTE:
9475 case KEY_CLOSEBRACE:
9476 case KEY_END:
9477 case KEY_HOME:
9478 case KEY_OPENBRACE:
9479 case KEY_PGDN:
9480 case KEY_PGUP:
9481 case KEY_TAB:
9482 case KEY_TILDE:
9483 83568276 return true;
9484 }
9485 1095672952 return is_Fkey(k);
9486 1179241228 }
9487
9488 9285364 void update_system_keys()
9489 {
9490
2/2
✓ Branch 0 taken 1179241228 times.
✓ Branch 1 taken 9285364 times.
1188526592 for (int32_t q = 0; q < 127; ++q)
9491 {
9492
2/2
✓ Branch 0 taken 194992644 times.
✓ Branch 1 taken 984248584 times.
1179241228 if (!is_system_key(q))
9493 984248584 continue;
9494
9495 194992644 key_system[q] = key[q];
9496
1/2
✓ Branch 0 taken 194992644 times.
✗ Branch 1 not taken.
194992644 key_system_press[q] = key_system[q] && !key_system_previous[q];
9497 194992644 key_system_previous[q] = key_system[q];
9498 194992644 }
9499 9285364 }
9500
9501 10388672 void update_keys()
9502 {
9503
2/2
✓ Branch 0 taken 1319361344 times.
✓ Branch 1 taken 10388672 times.
1329750016 for (int32_t q = 0; q < 127; ++q)
9504 {
9505 // When replaying, replay.cpp takes care of updating `key_current_frame`.
9506
1/2
✓ Branch 0 taken 1319361344 times.
✗ Branch 1 not taken.
1319361344 if (!replay_is_replaying())
9507 key_current_frame[q] = key[q];
9508
9509
2/2
✓ Branch 0 taken 1309576330 times.
✓ Branch 1 taken 9785014 times.
1319361344 KeyPress[q] = key_current_frame[q] && !key_previous_frame[q];
9510 1319361344 KeyInput[q] = key_current_frame[q];
9511 1319361344 key_previous_frame[q] = key_current_frame[q];
9512 1319361344 }
9513 10388672 }
9514
9515 bool zc_disablekey(int32_t k, bool val)
9516 {
9517 switch(k)
9518 {
9519 case KEY_F7:
9520 case KEY_F8:
9521 case KEY_F9:
9522 return false;
9523
9524 default:
9525 disabledKeys[k] = val;
9526 return true;
9527 }
9528 }
9529
9530 void zc_putpixel(int32_t layer, int32_t x, int32_t y, int32_t cset, int32_t color, int32_t timer)
9531 {
9532 timer=timer;
9533 particles.add(new particle(zfix(x), zfix(y), layer, cset, color));
9534 }
9535